From 6aab2439095f27a8f4c754343f8d8f6674576c2c Mon Sep 17 00:00:00 2001 From: Arnaud Bailly Date: Sun, 2 Nov 2025 21:38:48 +0100 Subject: better rendering for evaluation output --- lambda-calcul/haskell/public/repl.js | 4 +++- lambda-calcul/haskell/src/Minilang/REPL/Net.hs | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'lambda-calcul') diff --git a/lambda-calcul/haskell/public/repl.js b/lambda-calcul/haskell/public/repl.js index 599d1f8..1d4453f 100644 --- a/lambda-calcul/haskell/public/repl.js +++ b/lambda-calcul/haskell/public/repl.js @@ -51,7 +51,9 @@ function appendOutput(text) { function formatResult(text) { const result = JSON.parse(text); - if (result.tag === "Msg") { + if (result.rendered) { + return result.rendered; + } else if (result.tag === "Msg" ) { return result.contents; } return text; diff --git a/lambda-calcul/haskell/src/Minilang/REPL/Net.hs b/lambda-calcul/haskell/src/Minilang/REPL/Net.hs index 1bafeaa..43d2560 100644 --- a/lambda-calcul/haskell/src/Minilang/REPL/Net.hs +++ b/lambda-calcul/haskell/src/Minilang/REPL/Net.hs @@ -24,6 +24,7 @@ import Data.Text.Encoding (decodeUtf8With) import Data.Text.Encoding.Error (lenientDecode) import Minilang.Log import Minilang.REPL (withInputs) +import Minilang.REPL.Pure (render) import Minilang.REPL.Purer (purerREPL) import Minilang.REPL.Run (runREPL) import Minilang.REPL.Types @@ -92,7 +93,13 @@ instance MonadREPL (Net IO) where output a = do gets connection >>= lift . wsSend a - netLog (object ["action" .= ("output" :: Text), "content" .= a]) + netLog + ( object + [ "action" .= ("output" :: Text), + "content" .= a, + "rendered" .= render a + ] + ) prompt = pure () getEnv = gets repl >>= lift . readTVarIO -- cgit v1.3.1