[clean up E in Main after boxification, make parenthesis generation work properly for primitive arguments in E.ToHs
John Meacham <john@repetae.net>**20061114105824] hunk ./E/ToHs.hs 38
--- | get rid of unused bindings
-cleanupE :: E -> E
-cleanupE e = runIdentity (f e) where
-    f (ELam t@TVr { tvrIdent = v } e) | v /= 0, v `notMember` freeIds e = f (ELam t { tvrIdent = 0 } e)
-    f (EPi t@TVr { tvrIdent = v } e) | v /= 0, v `notMember` freeIds e = f (EPi t { tvrIdent = 0 } e)
-    f ec@ECase { eCaseBind = t@TVr { tvrIdent = v } } | v /= 0, v `notMember` (freeVars (caseBodies ec)::IdSet) = f ec { eCaseBind = t { tvrIdent = 0 } }
-    f e = emapEG f f e
hunk ./E/ToHs.hs 42
-    (v,_,Coll { collNames = ns, collPrims = prims }) <- runRWST (fromTM $ transE (cleanupE $ programE prog)) emptyEnvironment 1
+    (v,_,Coll { collNames = ns, collPrims = prims }) <- runRWST (fromTM $ transE (programE prog)) emptyEnvironment 1
hunk ./E/ToHs.hs 257
-    ("drop__",[_x,y]) -> transE y  -- XXX
-    ("catch__",args) -> mapM transE args >>= \args' -> mparen (return $ hsep (text "catch#":args'))
-    ("raiseIO__",args) -> mapM transE args >>= \args' -> mparen (return $ hsep (text "raiseIO#":args'))
-    ("newRef__",args) -> mapM transE args >>= \args' -> mparen (return $ hsep (text "newMVar#":args'))
-    ("readRef__",args) -> mapM transE args >>= \args' -> mparen (return $ hsep (text "readMutVar#":args'))
-    ("writeRef__",args) -> mapM transE args >>= \args' -> mparen (return $ hsep (text "writeMutVar#":args'))
-    _ -> return $ parens $ text "error" <+> tshow ("ToHs.Error: " ++ show e)
+    ("drop__",[_x,y])   -> transE y  -- XXX
+    ("catch__",args)    -> mparen $ mapM transE args >>= \args' -> return $ hsep (text "catch#":args')
+    ("raiseIO__",args)  -> mparen $ mapM transE args >>= \args' -> return $ hsep (text "raiseIO#":args')
+    ("newRef__",args)   -> mparen $ mapM transE args >>= \args' -> return $ hsep (text "newMVar#":args')
+    ("readRef__",args)  -> mparen $ mapM transE args >>= \args' -> return $ hsep (text "readMutVar#":args')
+    ("writeRef__",args) -> mparen $ mapM transE args >>= \args' -> return $ hsep (text "writeMutVar#":args')
+    _ -> mparen $ return $ text "error" <+> tshow ("ToHs.Error: " ++ show e)
hunk ./E/ToHs.hs 289
-transE e = return $ parens $ text "error" <+> tshow ("ToHs.Error: " ++ show e)
+transE e = mparen $ return $ text "error" <+> tshow ("ToHs.Error: " ++ show e)
hunk ./Main.hs 33
+import E.FreeVars
hunk ./Main.hs 714
+    prog <- return $ runIdentity $ programMapBodies (return . cleanupE) prog
hunk ./Main.hs 779
+-- | get rid of unused bindings
+cleanupE :: E -> E
+cleanupE e = runIdentity (f e) where
+    f (ELam t@TVr { tvrIdent = v } e) | v /= 0, v `notMember` freeIds e = f (ELam t { tvrIdent = 0 } e)
+    f (EPi t@TVr { tvrIdent = v } e) | v /= 0, v `notMember` freeIds e = f (EPi t { tvrIdent = 0 } e)
+    f ec@ECase { eCaseBind = t@TVr { tvrIdent = v } } | v /= 0, v `notMember` (freeVars (caseBodies ec)::IdSet) = f ec { eCaseBind = t { tvrIdent = 0 } }
+    f e = emapEG f f e