[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] Maybe, maybe not.

Subject: Re: [Haskell-cafe] Maybe, maybe not.
From: "Edward Z. Yang"
Date: Tue, 26 Jan 2010 22:52:30 -0500
Excerpts from michael rice's message of Tue Jan 26 21:34:42 -0500 2010:
> fromMaybe d x = case x of {Nothing -> d;Just v -> v}
> fromMaybe z = maybe z id

They're equivalent.  Here the definition of maybe:

    maybe :: b -> (a -> b) -> Maybe a -> b
    maybe n _ Nothing  = n
    maybe _ f (Just x) = f x

Cheers,
Edward
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>