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/REPL/Pure.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/REPL/Pure.hs')
| -rw-r--r-- | lambda-calcul/haskell/src/Minilang/REPL/Pure.hs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lambda-calcul/haskell/src/Minilang/REPL/Pure.hs b/lambda-calcul/haskell/src/Minilang/REPL/Pure.hs index 8250152..d9dbbbe 100644 --- a/lambda-calcul/haskell/src/Minilang/REPL/Pure.hs +++ b/lambda-calcul/haskell/src/Minilang/REPL/Pure.hs @@ -13,9 +13,9 @@ import qualified Minilang.Lambda.Unify as Type import Minilang.REPL.Types data PureEnv = PureEnv - { inputText :: [Text], - outputText :: [Text], - pureREPL :: REPLEnv + { inputText :: [Text] + , outputText :: [Text] + , pureREPL :: REPLEnv } newtype PureREPL a = PureREPL {runPure :: CatchT (State PureEnv) a} @@ -26,25 +26,30 @@ instance MonadREPL PureREPL where ins <- gets inputText case ins of [] -> pure EOF - (t : ts) -> modify (\e -> e {inputText = ts}) >> pure (interpret t) + (t : ts) -> modify (\e -> e{inputText = ts}) >> pure (interpret t) - output t = modify $ \e -> e {outputText = render t : outputText e} + output t = modify $ \e -> e{outputText = render t : outputText e} prompt = pure () getEnv = gets pureREPL - setEnv e' = modify $ \e -> e {pureREPL = e'} + setEnv e' = modify $ \e -> e{pureREPL = e'} load f = pure $ Left $ REPLError $ "cannot load file " <> f <> " in Pure interpreter" render :: Out -> Text render = \case Msg t -> t - Evaluated ast _term typ -> pretty ast <> " : " <> Type.pretty typ - Defined ident typ -> ident <> " : " <> Type.pretty typ + Evaluated ast _term typ -> pretty ast <> renderType typ + Defined ident typ -> ident <> renderType typ Bye -> "Bye!" other -> pack (show other) +renderType :: Maybe Type.Type -> Text +renderType typ = case typ of + Nothing -> "" + Just t -> " : " <> Type.pretty t + instance MonadThrow PureREPL where throwM = throw |
