
14 Jun
2011
14 Jun
'11
12:35 p.m.
Michael Xavier wrote:
You can pattern match to get the value out of it...
That is certainly true. But I find that I rarely do that, because we have so many nice functions for using Maybe values. The two most common and simplest are already enough that you almost never need to pattern match a Maybe: maybe :: a -> (b -> a) -> Maybe b -> a This applies a function to the value inside Just, or gives a default value when it's a Nothing. fromMaybe :: a -> Maybe a -> a -- from Data.Maybe Like "maybe", but just gives you the value inside the Just without applying a function. There are so many others. Regards, Yitz