
10 Jul
2007
10 Jul
'07
4:04 a.m.
tmorris:
When you you use maybe :: b -> (a -> b) -> Maybe a -> b instead of pattern matching a returned Maybe value?
Is there something a bit more concrete on this issue?
You mean, versus using 'case' or sugar for case? It'll just inline to the same code. For example: maybe 10 (\n -> n + 1) bigexpr => {inline maybe} (\n f x -> case x of Nothing -> n Just x -> f x) 10 (\n -> n + 1) bigexpr => {reduce} case bigexpr of Nothing -> 10 Just x -> x+1 So use 'maybe' if its clearer -- it doesn't cost anything. -- Don