Just noticed this difference in the definition of fromMaybe in two different
places:
http://haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/src/Data-Maybe.html#fromMaybe
-- | The 'fromMaybe' function takes a default value and and 'Maybe'
-- value. If the 'Maybe' is 'Nothing', it
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
Didn't recognize the sameness. Aside from there being many ways to do the same
thing, partial application makes the mixup even merrier.
Thanks,
Michael
--- On Tue, 1/26/10, Edward Z. Yang ezy...@mit.edu wrote:
From: Edward Z. Yang ezy...@mit.edu
Subject: Re: [Haskell-cafe] Maybe, maybe
the mixup even merrier.
Thanks,
Michael
--- On *Tue, 1/26/10, Edward Z. Yang ezy...@mit.edu* wrote:
From: Edward Z. Yang ezy...@mit.edu
Subject: Re: [Haskell-cafe] Maybe, maybe not.
To: michael rice nowg...@yahoo.com
Cc: haskell-cafe haskell-cafe@haskell.org
Date: Tuesday, January 26
Excerpts from Daniel Peebles's message of Tue Jan 26 23:25:28 -0500 2010:
There are actually only two (extensionally) possible total functions with
that type, as far as I can see :)
Is the other one... const?
Cheers,
Edward
___
Haskell-Cafe mailing
2010/1/27 Edward Z. Yang ezy...@mit.edu:
Excerpts from Daniel Peebles's message of Tue Jan 26 23:25:28 -0500 2010:
There are actually only two (extensionally) possible total functions with
that type, as far as I can see :)
Is the other one... const?
As far as I can tell, yes.
--
Ivan Lazar
It might be more obvious by giving:
fromMaybe :: a - (a - x, x) - x
Ivan Miljenovic wrote:
2010/1/27 Edward Z. Yang ezy...@mit.edu:
Excerpts from Daniel Peebles's message of Tue Jan 26 23:25:28 -0500 2010:
There are actually only two (extensionally) possible total functions with
2010/1/27 Tony Morris tonymor...@gmail.com:
It might be more obvious by giving:
fromMaybe :: a - (a - x, x) - x
I actually found this more confusing, and am not sure of its validity:
should that be Maybe a there at the beginning?
--
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
Ivan Miljenovic wrote:
2010/1/27 Tony Morris tonymor...@gmail.com:
It might be more obvious by giving:
fromMaybe :: a - (a - x, x) - x
I actually found this more confusing, and am not sure of its validity:
should that be Maybe a there at the beginning?
Sorry a mistake.