HaskellWiki

Haskell | Wiki community | Recent changes
Random page | Special pages

 

Not logged in
Log in | Help

Talk:Correctness of short cut fusion

If unfoldr would use a lazy pattern match:

unfoldr :: (b -> Maybe (a,b)) -> b -> [a]
unfoldr p e = case p e of Nothing     -> []
                          Just ~(x,e') -> x:unfoldr p e'

the left hand side of the example without seq will be the same as the right hand side:

destroy g (unfoldr p e) = g step (unfoldr p e)
                        = case step (unfoldr p e) of Just z -> 0
                        = case step (case p e of Nothing     -> []
                                                 Just ~(x,e') -> x:unfoldr p e') of Just z -> 0
                        = case step (case Just undefined of Nothing     -> []
                                                            Just ~(x,e') -> x:unfoldr p e') of Just z -> 0
                        = case step (undefined:unfoldr p undefined) of Just z -> 0
                        = case Just (undefined,unfoldr p undefined) of Just z -> 0
                        = 0

--Twanvl 12:18, 13 February 2007 (UTC)

Retrieved from "http://www.haskell.org/haskellwiki/Talk:Correctness_of_short_cut_fusion"

This page has been accessed 384 times. This page was last modified 12:18, 13 February 2007. Recent content is available under a simple permissive license.