diff options
| author | Arnaud Bailly <arnaud@pankzsoft.com> | 2025-11-02 18:18:50 +0100 |
|---|---|---|
| committer | Arnaud Bailly <arnaud@pankzsoft.com> | 2025-11-02 18:18:50 +0100 |
| commit | d8e4ef2a4611682e273ca18189b1bebf791a1bb8 (patch) | |
| tree | 64f95ac3e30a6a2a7898da300f982257202f4393 /lambda-calcul/haskell/src/Minilang/REPL/Pure.hs | |
| parent | 00ef8caacaa576b4045d43a5bdddd81a2d093496 (diff) | |
| download | lambda-nantes-d8e4ef2a4611682e273ca18189b1bebf791a1bb8.tar.gz | |
fix tests and add HTML stuff to deployment
Diffstat (limited to 'lambda-calcul/haskell/src/Minilang/REPL/Pure.hs')
| -rw-r--r-- | lambda-calcul/haskell/src/Minilang/REPL/Pure.hs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lambda-calcul/haskell/src/Minilang/REPL/Pure.hs b/lambda-calcul/haskell/src/Minilang/REPL/Pure.hs index 23c45e1..91e71b9 100644 --- a/lambda-calcul/haskell/src/Minilang/REPL/Pure.hs +++ b/lambda-calcul/haskell/src/Minilang/REPL/Pure.hs @@ -8,6 +8,8 @@ import Control.Monad.Catch import Control.Monad.Catch.Pure (CatchT (..)) import Control.Monad.State import Data.Text hiding (replicate) +import Minilang.Lambda.Parser (pretty, resugar) +import qualified Minilang.Lambda.Unify as Type import Minilang.REPL.Types data PureEnv = PureEnv @@ -21,20 +23,25 @@ newtype PureREPL a = PureREPL {runPure :: CatchT (State PureEnv) a} instance MonadREPL PureREPL where input = do - ins <- inputText <$> get + ins <- gets inputText case ins of [] -> pure EOF (t : ts) -> modify (\e -> e {inputText = ts}) >> pure (interpret t) output t = modify $ \e -> e {outputText = render t : outputText e} + prompt = pure () - getEnv = get >>= pure . pureREPL + + getEnv = gets pureREPL + 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 term typ -> pretty (resugar term) <> " : " <> Type.pretty typ Bye -> "Bye!" other -> pack (show other) |
