diff options
| author | Arnaud Bailly <arnaud@pankzsoft.com> | 2026-04-01 16:18:01 +0200 |
|---|---|---|
| committer | Arnaud Bailly <arnaud@pankzsoft.com> | 2026-04-01 16:22:02 +0200 |
| commit | f6dde1041a52da4f2e7ccb77eed3c577f9d07798 (patch) | |
| tree | ee99b8a606b7dcb378744f62245209a7d4d8eda4 /lambda-calcul/haskell/src/Minilang/API.hs | |
| parent | d820a635afb69c44f736e941bbe094ad6a838073 (diff) | |
| download | lambda-nantes-f6dde1041a52da4f2e7ccb77eed3c577f9d07798.tar.gz | |
Remove answers from sent challenges
Also fix integration test
Diffstat (limited to 'lambda-calcul/haskell/src/Minilang/API.hs')
| -rw-r--r-- | lambda-calcul/haskell/src/Minilang/API.hs | 72 |
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?" ] |
