From f6dde1041a52da4f2e7ccb77eed3c577f9d07798 Mon Sep 17 00:00:00 2001 From: Arnaud Bailly Date: Wed, 1 Apr 2026 16:18:01 +0200 Subject: Remove answers from sent challenges Also fix integration test --- lambda-calcul/haskell/src/Minilang/API.hs | 72 +++++++++++++++---------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'lambda-calcul/haskell/src/Minilang/API.hs') 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?" ] -- cgit v1.3.1