Tests and better default REPL behavior

This commit is contained in:
James Eversole
2024-12-27 14:10:13 -06:00
parent dbb5227fbc
commit 4495f8eba0
5 changed files with 106 additions and 92 deletions

View File

@ -10,7 +10,18 @@ import qualified Data.Map as Map
import Text.Megaparsec (runParser)
main :: IO ()
main = repl Map.empty --(Map.fromList [("__result", Leaf)])
main = repl library
runSapling :: String -> String
runSapling s = show $ result (evalSapling Map.empty $ parseSapling s)
library = evalSapling Map.empty $ parseSapling
"false = t\n \
\ true = t t\n \
\ id = (\\a : a)\n \
\ triage = (\\a b c : t (t a b) c)\n \
\ match_bool = (\\ot of : triage of (\\z : ot) t)\n \
\ and = match_bool id (\\z : false)\n \
\ if = (\\cond then else : t (t else (t t then)) t cond)"
runSaplingEnv env s = show $ result (evalSapling env $ parseSapling s)