
14 Dec
2011
14 Dec
'11
6:51 a.m.
On Wed, Dec 14, 2011 at 1:49 PM, Bas van Dijk
Hello,
When looking at the Alternative instance of Maybe I noticed that the <|> combinator doesn't share it's first argument when it could. So I propose to make the following change:
instance Alternative Maybe where empty = Nothing - Nothing <|> p = p - Just x <|> _ = Just x + Nothing <|> r = r + l <|> _ = l
Since this isn't a change in the API, I guess this doesn't need to go through the library submission process.
http://hackage.haskell.org/trac/ghc/ticket/5699
Cheers,
Bas
+1 Out of curiosity, does this actually bypass an extra allocation, or is GHC smart enough to notice the possibility to share? Michael