@@ -213,43 +213,55 @@ usedIn env (LOp f args) = concatMap (usedIn env) args
213213usedIn env _ = []
214214
215215instance Show LExp where
216− show e = show' [] e where
217− show' env (LV (Loc i)) = env!!i
218− show' env (LV (Glob n)) = show n
219− show' env (LLazyApp e args) = show e ++ "|(" ++
220− showSep ", " (map (show' env) args) ++")"
221− show' env (LApp _ e args) = show' env e ++ "(" ++
222− showSep ", " (map (show' env) args) ++")"
223− show' env (LLazyExp e) = "lazy{ " ++ 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 " ++
226− show' (env ++ [show n]) e
227− show' env (LLam args e) = "\\ " ++ showSep "," (map show args) ++ " => " ++
228− show' (env ++ (map show args)) e
229− show' env (LProj t i) = show t ++ "!" ++ show i
230− show' env (LCon i n args) = show n ++ ")" ++ showSep ", " (map (show' env) args) ++ ")"
231− show' env (LCase e alts) = "case " ++ show' env e ++ " of \n" ++
232− unlines (map (("\t | " ++) . showAlt env) alts)
233− show' env (LConst c) = show c
234− show' env (LForeign lang ty n args) = concat
216+ show e = show' [] "" e where
217+ show' env ind (LV (Loc i)) = env!!i
218+ show' env ind (LV (Glob n)) = show n
219+
220+ show' env ind (LLazyApp e args)
221+ = show e ++ "|(" ++ showSep ", " (map (show' env ind) args) ++")"
222+
223+ show' env ind (LApp _ e args)
224+ = show' env ind e ++ "(" ++ showSep ", " (map (show' env ind) args) ++")"
225+
226+ show' env ind (LLazyExp e) = "lazy{ " ++ show' env ind e ++ " }"
227+ show' env ind (LForce e) = "force{ " ++ show' env ind e ++ " }"
228+ show' env ind (LLet n v e)
229+ = "let " ++ show n ++ " = " ++ show' env ind v
230+ ++ " in " ++ show' (env ++ [show n]) ind e
231+
232+ show' env ind (LLam args e)
233+ = "\\ " ++ showSep "," (map show args)
234+ ++ " => " ++ show' (env ++ (map show args)) ind e
235+
236+ show' env ind (LProj t i) = show t ++ "!" ++ show i
237+
238+ show' env ind (LCon i n args)
239+ = show n ++ "(" ++ showSep ", " (map (show' env ind) args) ++ ")"
240+
241+ show' env ind (LCase e alts)
242+ = "case " ++ show' env ind e ++ " of \n" ++
243+ intercalate "\n" ["\t" ++ ind ++ " | " ++ showAlt env (" " ++ ind) alt | alt <- alts]
244+
245+ show' env ind (LConst c) = show c
246+
247+ show' env ind (LForeign lang ty n args) = concat
235248 [ "foreign{ "
236249 , n ++ "("
237− , showSep ", " (map (\(ty,x) -> show' env x ++ " : " ++ show ty) args)
250+ , showSep ", " (map (\(ty,x) -> show' env ind x ++ " : " ++ show ty) args)
238251 , ") : "
239252 , show ty
240253 , " }"
241254 ]
242255
243− show' env (LOp f args) = show f ++ "(" ++ showSep ", " (map (show' env) args) ++ ")"
244− show' env (LError str) = "error " ++ show str
245− show' env LNothing = "____"
246−
247− showAlt env (LConCase _ n args e)
248− = show n ++ "(" ++ showSep ", " (map show args) ++ ") => "
249− ++ show' env e
250− showAlt env (LConstCase c e) = show c ++ " => " ++ show' env e
251− showAlt env (LDefaultCase e) = "_ => " ++ show' env e
252−
256+ show' env ind (LOp f args)
257+ = show f ++ "(" ++ showSep ", " (map (show' env ind) args) ++ ")"
253258
259+ show' env ind (LError str) = "error " ++ show str
260+ show' env ind LNothing = "____"
254261
262+ showAlt env ind (LConCase _ n args e)
263+ = show n ++ "(" ++ showSep ", " (map show args) ++ ") => "
264+ ++ show' env ind e
255265
266+ showAlt env ind (LConstCase c e) = show c ++ " => " ++ show' env ind e
267+ showAlt env ind (LDefaultCase e) = "_ => " ++ show' env ind e