@@ -40,7 +40,6 @@ data Expr = IntNum Int
40 | Binop String CExpr CExpr
40 | Binop String CExpr CExpr
41 | Lambda String CExpr
41 | Lambda String CExpr
42 | App CExpr CExpr
42 | App CExpr CExpr
43− | If CExpr CExpr CExpr
44 | MultiIf [(CExpr,CExpr)]
43 | MultiIf [(CExpr,CExpr)]
45 | Let [Def] CExpr
44 | Let [Def] CExpr
46 | Var String
45 | Var String
@@ -118,7 +117,6 @@ instance Show Expr where
118 Lambda x e -> let (xs,e') = getLambdas (notLocated $ Lambda x e) in
117 Lambda x e -> let (xs,e') = getLambdas (notLocated $ Lambda x e) in
119 concat [ "\\", intercalate " " xs, " -> ", show e' ]
118 concat [ "\\", intercalate " " xs, " -> ", show e' ]
120 App e1 e2 -> show' e1 ++ " " ++ show' e2
119 App e1 e2 -> show' e1 ++ " " ++ show' e2
121− If e1 e2 e3 -> concat [ "if ", show e1, " then ", show e2, " else ", show e3 ]
122 MultiIf (p:ps) -> concat [ "if | ", iff p, sep (map iff ps) ]
120 MultiIf (p:ps) -> concat [ "if | ", iff p, sep (map iff ps) ]
123 where iff (b,e) = show b ++ " -> " ++ show e
121 where iff (b,e) = show b ++ " -> " ++ show e
124 sep = concatMap ("\n | " ++)
122 sep = concatMap ("\n | " ++)
@@ -149,10 +147,10 @@ getLambdas e = ([],e)
149needsParens e =
147needsParens e =
150 case e of
148 case e of
151 Binop _ _ _ -> True
149 Binop _ _ _ -> True
152− Lambda _ _ -> True
150+ Lambda _ _ -> True
153− App _ _ -> True
151+ App _ _ -> True
154− If _ _ _ -> True
152+ MultiIf _ -> True
155− Let _ _ -> True
153+ Let _ _ -> True
156− Case _ _ -> True
154+ Case _ _ -> True
157 Data name (x:xs) -> name /= "Cons"
155 Data name (x:xs) -> name /= "Cons"
158 _ -> False
156 _ -> False