summaryrefslogtreecommitdiff
path: root/lambda-calcul/haskell/src/Minilang/REPL/Run.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lambda-calcul/haskell/src/Minilang/REPL/Run.hs')
-rw-r--r--lambda-calcul/haskell/src/Minilang/REPL/Run.hs17
1 files changed, 5 insertions, 12 deletions
diff --git a/lambda-calcul/haskell/src/Minilang/REPL/Run.hs b/lambda-calcul/haskell/src/Minilang/REPL/Run.hs
index 37d4dd2..3984dec 100644
--- a/lambda-calcul/haskell/src/Minilang/REPL/Run.hs
+++ b/lambda-calcul/haskell/src/Minilang/REPL/Run.hs
@@ -15,7 +15,7 @@ import Minilang.Lambda.DeBruijn (eval, fromDeBruijn, toDeBruijn)
import Minilang.Lambda.Eval (newEnv)
import Minilang.Lambda.Infer (infer, newContext)
import qualified Minilang.Lambda.Infer as Infer
-import Minilang.Lambda.Parser (desugar, parse)
+import Minilang.Lambda.Parser (desugar, parse, resugar)
import Minilang.Lambda.Unify (Type (TyVar))
import Minilang.REPL.Types
@@ -43,15 +43,16 @@ handleUserInput txt = do
Right expr -> do
let term = desugar expr
v = fromDeBruijn $ eval (toDeBruijn term)
+ ast = resugar v
case language of
Typed ->
case infer term of
Left typeError -> output (Msg $ Infer.render typeError)
Right typ -> do
let
- output (Evaluated v typ)
+ output (Evaluated ast v typ)
Untyped ->
- output (Evaluated v (TyVar "<?>"))
+ output (Evaluated ast v (TyVar "<?>"))
handleCommand ::
(MonadCatch m, MonadREPL m) =>
@@ -89,12 +90,4 @@ loadProgramInEnv prog = do
Left typeError -> output (Msg $ pack $ show typeError)
Right (term, typ, env', context') -> do
setEnv (repl {env = env', context = context'})
- output (Evaluated term typ)
- where
- makeMessage =
- "Loaded \""
- <> ( if Text.length prog > 15
- then Text.take 15 prog <> "..."
- else prog
- )
- <> "\""
+ output (Evaluated (resugar term) term typ)