on master help sign in
Unified printing of special LTerms.
bc79ee8Matus Tejiscak
src/IRTS/Lang.hs+3−3
@@ -220,8 +220,8 @@ instance Show LExp where
220 showSep ", " (map (show' env) args) ++")"
220 showSep ", " (map (show' env) args) ++")"
221 show' env (LApp _ e args) = show' env e ++ "(" ++
221 show' env (LApp _ e args) = show' env e ++ "(" ++
222 showSep ", " (map (show' env) args) ++")"
222 showSep ", " (map (show' env) args) ++")"
223− show' env (LLazyExp e) = "%lazy(" ++ show' env e ++ ")"
223+ show' env (LLazyExp e) = "lazy{ " ++ show' env e ++ " }"
224− show' env (LForce e) = "%force(" ++ show' env e ++ ")"
224+ show' env (LForce e) = "force{ " ++ show' env e ++ " }"
225 show' env (LLet n v e) = "let " ++ show n ++ " = " ++ show' env v ++ " in " ++
225 show' env (LLet n v e) = "let " ++ show n ++ " = " ++ show' env v ++ " in " ++
226 show' (env ++ [show n]) e
226 show' (env ++ [show n]) e
227 show' env (LLam args e) = "\\ " ++ showSep "," (map show args) ++ " => " ++
227 show' env (LLam args e) = "\\ " ++ showSep "," (map show args) ++ " => " ++
@@ -232,7 +232,7 @@ instance Show LExp where
232 showSep "\n\t| " (map (showAlt env) alts)
232 showSep "\n\t| " (map (showAlt env) alts)
233 show' env (LConst c) = show c
233 show' env (LConst c) = show c
234 show' env (LForeign lang ty n args) = concat
234 show' env (LForeign lang ty n args) = concat
235− [ "foreign { "
235+ [ "foreign{ "
236 , n ++ "("
236 , n ++ "("
237 , showSep ", " (map (\(ty,x) -> show' env x ++ " : " ++ show ty) args)
237 , showSep ", " (map (\(ty,x) -> show' env x ++ " : " ++ show ty) args)
238 , ") : "
238 , ") : "
test/basic007/test033.idr+9−1
@@ -1,4 +1,12 @@
1module Main
1module Main
2
2
3+%flag C "-ggdb3 -O0 -Q"
4+
5+isn : String -> IO Int
6+isn s = mkForeign (FFun "isNull" [FString] FInt ) s
7+
8+prn : String -> IO ()
9+prn s = mkForeign (FFun "putStr" [FString] FUnit) s
10+
3main : IO ()
11main : IO ()
4−main = nullPtr null >>= (putStrLn . show)
12+main = isn "\n" >>= print