summaryrefslogtreecommitdiff
path: root/lambda-calcul/haskell/src/Minilang/API.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lambda-calcul/haskell/src/Minilang/API.hs')
-rw-r--r--lambda-calcul/haskell/src/Minilang/API.hs72
1 files changed, 36 insertions, 36 deletions
diff --git a/lambda-calcul/haskell/src/Minilang/API.hs b/lambda-calcul/haskell/src/Minilang/API.hs
index 0be70ff..9638da8 100644
--- a/lambda-calcul/haskell/src/Minilang/API.hs
+++ b/lambda-calcul/haskell/src/Minilang/API.hs
@@ -17,25 +17,25 @@ import Data.Data (Proxy (..))
import Data.Text (Text)
import Data.Time (UTCTime)
import GHC.Generics (Generic)
-import Servant
- ( Delete,
- Description,
- FromHttpApiData,
- Get,
- JSON,
- Post,
- QueryParam,
- Raw,
- ReqBody,
- StdMethod (POST),
- Summary,
- ToHttpApiData,
- Verb,
- parseUrlPiece,
- toUrlPiece,
- (:<|>),
- (:>),
- )
+import Servant (
+ Delete,
+ Description,
+ FromHttpApiData,
+ Get,
+ JSON,
+ Post,
+ QueryParam,
+ Raw,
+ ReqBody,
+ StdMethod (POST),
+ Summary,
+ ToHttpApiData,
+ Verb,
+ parseUrlPiece,
+ toUrlPiece,
+ (:<|>),
+ (:>),
+ )
import System.Random (StdGen, uniformList)
type LambdaAPI =
@@ -91,12 +91,13 @@ type GetNextChallenge =
type PostAnswer =
Summary
- "Post an answer to the current challenge for the given user." :>
- Description "The answer should be given as JSON string representing the result \
- \of evaluating the current challenge's expression in the untyped λ-calculus. This \
- \textual representation should be consistent with the grammar given in the REPL's \
- \\"Help\" panel. Expect to be surprised 🤔 !\
- \"
+ "Post an answer to the current challenge for the given user."
+ :> Description
+ "The answer should be given as JSON string representing the result \
+ \of evaluating the current challenge's expression in the untyped λ-calculus. This \
+ \textual representation should be consistent with the grammar given in the REPL's \
+ \\"Help\" panel. Expect to be surprised 🤔 !\
+ \"
:> "api"
:> "challenge"
:> QueryParam "token" Token
@@ -107,10 +108,10 @@ lambdaAPI :: Proxy LambdaAPI
lambdaAPI = Proxy
data Score = Score
- { user :: User,
- grade :: Int,
- lastTest :: Maybe UTCTime,
- lastResult :: Maybe Bool
+ { user :: User
+ , grade :: Int
+ , lastTest :: Maybe UTCTime
+ , lastResult :: Maybe Bool
}
deriving (Eq, Show, Generic, ToJSON, FromJSON)
@@ -130,16 +131,15 @@ newToken :: StdGen -> (ByteString, StdGen)
newToken = first LBS.pack . uniformList 16
data Challenge = Challenge
- { level :: Int,
- expr :: Text,
- description :: Text,
- answer :: Text
+ { level :: Int
+ , expr :: Text
+ , description :: Text
}
deriving (Eq, Show, Generic, ToJSON, FromJSON)
defaultChallenges :: [Challenge]
defaultChallenges =
- [ Challenge 0 "x" "A lone free variable. What does x reduce to?" "x",
- Challenge 1 "y" "Another free variable. What does y reduce to?" "y",
- Challenge 2 "(lam (x) x)" "The identity function. What is its normal form?" "(lam (x) x)"
+ [ Challenge 0 "x" "A lone free variable. What does x reduce to?"
+ , Challenge 1 "y" "Another free variable. What does y reduce to?"
+ , Challenge 2 "(lam (x) x)" "The identity function. What is its normal form?"
]