From 14b95f90b5da3822a9edcf0cfff84205885f51f6 Mon Sep 17 00:00:00 2001 From: James Eversole Date: Fri, 27 Dec 2024 20:54:30 -0600 Subject: [PATCH] Update README and REPL formatting for list outputs --- README.md | 25 +++++++++++++------------ src/REPL.hs | 3 ++- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index e47bea8..4fa8519 100644 --- a/README.md +++ b/README.md @@ -16,25 +16,26 @@ This is an active experimentation project by [someone who has no idea what they' ## What does it look like? ``` -false = t -true = t t -id = (\\a : a) -triage = (\\a b c : t (t a b) c) -match_bool = (\\ot of : triage of (\\z : ot) t) -and = match_bool id (\\z : false) -if = (\\cond then else : t (t else (t t then)) t cond) -triage = (\\a b c : t (t a b) c) -test = triage \"leaf\" (\\z : \"stem\") (\\a b : \"fork\") +false = t +_ = t +true = t t +id = (\a : a) +triage = (\a b c : t (t a b) c) +match_bool = (\ot of : triage of (\_ : ot) t) +and = match_bool id (\_ : false) +if = (\cond then else : t (t else (t t then)) t cond) +triage = (\a b c : t (t a b) c) +test = triage "leaf" (\_ : "stem") (\_ _ : "fork") +-- The REPL outputs the tree form results by default; they are elided here. sapling < test t -sapling > Fork (...) DECODE -: "leaf" sapling < test (t t) -sapling > Fork (...) DECODE -: "stem" sapling < test (t t t) -sapling > Fork (...) DECODE -: "fork" +sapling < map (\i : listConcat i " is super cool!") [("He") ("She") ("Everybody")] +DECODE -: ["He is super cool!", "She is super cool!", "Everybody is super cool!"] ``` ## How to use diff --git a/src/REPL.hs b/src/REPL.hs index 4f6f0bb..db2b66f 100644 --- a/src/REPL.hs +++ b/src/REPL.hs @@ -6,6 +6,7 @@ import Parser import Research import Control.Monad (void) +import Data.List (intercalate) import qualified Data.Map as Map import System.Console.Haskeline import System.IO (hFlush, stdout) @@ -38,5 +39,5 @@ decodeResult tc = case ofNumber tc of Left _ -> case ofString tc of Right str -> "\"" ++ str ++ "\"" Left _ -> case ofList tc of - Right list -> "[" ++ unlines (map decodeResult list) ++ "]" + Right list -> "[" ++ intercalate ", " (map decodeResult list) ++ "]" Left _ -> ""