on master help sign in
--dumpcases now dumps post unused arg erasure
commita04b57d2d4ac15255b219f9a29c0e5915de6a4bb authorEdwin Brady <ecb10@st-andrews.ac.uk> dateSat 20 Oct 2012, 18:14 (14 years ago) parent8327dc9
2 files changed+8−12
src/IRTS/Compiler.hs+6−12 src/IRTS/Lang.hs+2
src/IRTS/Compiler.hs+6−12
@@ -54,8 +54,7 @@ compile target f tm
5454 dumpDefun <- getDumpDefun
5555 case dumpCases of
5656 Nothing -> return ()
57− Just f -> do cs <- getCaseTrees (concat used)
58− liftIO $ writeFile f (showCaseTrees cs)
57+ Just f -> liftIO $ writeFile f (showCaseTrees tagged)
5958 case dumpDefun of
6059 Nothing -> return ()
6160 Just f -> liftIO $ writeFile f (dumpDefuns defuns)
@@ -99,18 +98,13 @@ mkDecls t used
9998 decls <- mapM build ds
10099 return decls
101100
102−getCaseTrees :: [Name] -> Idris [(Name, Def)]
103−getCaseTrees used
104− = do i <- getIState
105− let ds = filter (\ (n, d) -> n `elem` used || isCon d) $ ctxtAlist (tt_ctxt i)
106− return ds
107−
108−showCaseTrees :: [(Name, Def)] -> String
101+showCaseTrees :: [(Name, LDecl)] -> String
109102showCaseTrees ds = showSep "\n\n" (map showCT ds)
110103 where
111− showCT (n, CaseOp _ _ _ _ _ args sc)
112− = show n ++ " " ++ showSep " " (map show args) ++ " = " ++ show sc
113− showCT (n, _) = ""
104+ showCT (n, LFun f args lexp)
105+ = show n ++ " " ++ showSep " " (map show args) ++ " =\n\t "
106+ ++ show lexp
107+ showCT (n, LConstructor c t a) = "data " ++ show n ++ " " ++ show a
114108
115109isCon (TyDecl _ _) = True
116110isCon _ = False
src/IRTS/Lang.hs+2
@@ -172,6 +172,8 @@ instance Show LExp where
172172 show e = show' [] e where
173173 show' env (LV (Loc i)) = env!!i
174174 show' env (LV (Glob n)) = show n
175+ show' env (LLazyApp e args) = show e ++ "|(" ++
176+ showSep ", " (map (show' env) args) ++")"
175177 show' env (LApp _ e args) = show' env e ++ "(" ++
176178 showSep ", " (map (show' env) args) ++")"
177179 show' env (LLazyExp e) = "%lazy(" ++ show' env e ++ ")"