Skip to content
  • Simon Peyton Jones's avatar
    Teach SpecConstr how to handle mutually-recursive functions · 9fad5a80
    Simon Peyton Jones authored
    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!
    
    
    9fad5a80