From 4807eb0cbe44f53299dec7fd81a564e7c28703c6 Mon Sep 17 00:00:00 2001 From: Ivy Date: Sat, 30 Jan 2021 22:07:16 +0100 Subject: [PATCH] Changed display of expressions --- src/ExprType.hs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/ExprType.hs b/src/ExprType.hs index 458f202..ba10cd9 100644 --- a/src/ExprType.hs +++ b/src/ExprType.hs @@ -7,9 +7,16 @@ data Expr = IntE Integer | LambdaE String Expr | QuotedE Expr | NilE - deriving (Show) --- instance Show Expr where --- show (IntE x) = show x --- show (VarE x) = x ++ " ; var" --- show NilE = "nil" +-- Make set! and lambda(?) parsed as cons, detect later set! and lambda as special procedures + +instance Show Expr where + show (IntE x) = show x + show (VarE x) = x + show (SetE _ _) = "#set" + show c@(ConsE _ _) = "(" ++ showCons c + where showCons (ConsE _ NilE) = ")" + showCons (ConsE x xs) = show x ++ " " ++ showCons xs + show (LambdaE s e) = "#lambda" + show (QuotedE e) = show e + show NilE = "nil"