summaryrefslogtreecommitdiff
path: root/lambda-calcul/haskell/src
diff options
context:
space:
mode:
authorArnaud Bailly <arnaud@pankzsoft.com>2026-03-21 09:06:47 +0100
committerArnaud Bailly <arnaud@pankzsoft.com>2026-03-21 09:06:47 +0100
commitfade9c496cebbc0caa97821cb85e9e56da31c57f (patch)
tree7dd30194f57fad64de18584c08385e0e7107eb68 /lambda-calcul/haskell/src
parentcbc3ebfca24c89c475b9970fa525055d8291ee88 (diff)
downloadlambda-nantes-fade9c496cebbc0caa97821cb85e9e56da31c57f.tar.gz
Add more challenges and plans for enhancement of the interpreter
Diffstat (limited to 'lambda-calcul/haskell/src')
-rw-r--r--lambda-calcul/haskell/src/Minilang/API.hs10
-rw-r--r--lambda-calcul/haskell/src/Minilang/App.hs6
2 files changed, 9 insertions, 7 deletions
diff --git a/lambda-calcul/haskell/src/Minilang/API.hs b/lambda-calcul/haskell/src/Minilang/API.hs
index 43baddf..0be70ff 100644
--- a/lambda-calcul/haskell/src/Minilang/API.hs
+++ b/lambda-calcul/haskell/src/Minilang/API.hs
@@ -131,13 +131,15 @@ newToken = first LBS.pack . uniformList 16
data Challenge = Challenge
{ level :: Int,
- expr :: Text
+ expr :: Text,
+ description :: Text,
+ answer :: Text
}
deriving (Eq, Show, Generic, ToJSON, FromJSON)
defaultChallenges :: [Challenge]
defaultChallenges =
- [ Challenge 0 "x",
- Challenge 1 "y",
- Challenge 2 "(lam (x) x)"
+ [ 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)"
]
diff --git a/lambda-calcul/haskell/src/Minilang/App.hs b/lambda-calcul/haskell/src/Minilang/App.hs
index 915f264..cce48f7 100644
--- a/lambda-calcul/haskell/src/Minilang/App.hs
+++ b/lambda-calcul/haskell/src/Minilang/App.hs
@@ -151,11 +151,11 @@ postAnswer (Just token) expected = do
result = evaluateOutputs outputs expected
updateUserLastTest token result
case result of
- TestSucceeded -> do
+ TestSucceeded ->
upgradeUserChallenge token
TestFailed msg ->
liftIO $ throwM $ err400 {errBody = "Test failed: " <> LBS.fromStrict (encodeUtf8 msg)}
- TestErrored msg -> do
+ TestErrored msg ->
liftIO $ throwM $ err500 {errBody = "Error evaluating answer: " <> LBS.fromStrict (encodeUtf8 msg)}
data TestResult = TestSucceeded | TestFailed Text | TestErrored Text
@@ -167,7 +167,7 @@ isSuccess _ = False
evaluateOutputs :: [Out] -> Text -> TestResult
evaluateOutputs outputs expected =
case outputs of
- [Bye, Evaluated ast _ _] -> do
+ [Bye, Evaluated ast _ _] ->
if pretty ast /= expected
then TestFailed "Incorrect result"
else TestSucceeded