patch applied (ghc): Teach SpecConstr how to handle mutually-recursive functions
Simon Peyton Jones <[email protected]>
| Newsgroups | gmane.comp.lang.haskell.cvs.all |
|---|---|
| Message-ID | <20061130021721.GA2882__28919.9009574533$1164853063$gmane$org@cvs.haskell.org> |
Wed Nov 29 13:39:31 PST 2006 [email protected] * Teach SpecConstr how to handle mutually-recursive functions Roman found cases where it was important to do SpecConstr for mutually-recursive definitions. Here is one: foo :: Maybe Int -> Int foo Nothing = 0 foo (Just 0) = foo Nothing foo (Just n) = foo (Just (n-1)) By the time SpecConstr gets to it, it looks like this: lvl = foo Nothing foo Nothing = 0 foo (Just 0) = lvl foo (Just n) = foo (Just (n-1)) Happily, it turns out to be rather straightforward to generalise the transformation to mutually-recursive functions. Look, ma, only 4 extra lines of ocde! M ./compiler/specialise/SpecConstr.lhs -72 +76