[cache expFuncCalls and expIsNormal inside of Let constructor
John Meacham <john@repetae.net>**20060817033026] hunk ./Grin/Grin.hs 160
+                  expFuncCalls :: (Set.Set Atom,Set.Set Atom),            -- ^ cache
+                  expIsNormal :: Bool,                                    -- ^ cache, True = definitely normal, False = maybe normal
hunk ./Grin/Noodle.hs 11
+import Util.Gen
hunk ./Grin/Noodle.hs 114
-        cfunc Let { expDefs = defs, expBody = body } = do
-            b <- cfunc body
-            rs <- mapM (clfunc . funcDefBody) defs
-            return $ mconcat (b:rs)
+        cfunc Let { expFuncCalls = (tail,nonTail) } = do
+            tell nonTail
+            return tail
hunk ./Grin/Noodle.hs 130
-grinLet defs body = updateLetProps Let { expDefs = defs, expBody = body, expInfo = mempty }
+grinLet defs body = updateLetProps Let {
+    expDefs = defs,
+    expBody = body,
+    expInfo = mempty,
+    expIsNormal = False,
+    expFuncCalls = undefined }
hunk ./Grin/Noodle.hs 138
-updateLetProps lt@Let {} = lt
+updateLetProps lt@Let { expBody = body, expDefs = defs } = lt { expFuncCalls = (tail Set.\\ myDefs, nonTail Set.\\ myDefs), expIsNormal = not isNotNormal } where
+    (tail,nonTail) = mconcatMap collectFuncs (body : map (lamExp . funcDefBody) defs)
+    isNotNormal = any ((`Set.member` nonTail) . funcDefName) defs
+    myDefs = Set.fromList (map funcDefName defs)