Re: [Haskell-cafe] Questions about the Functor class and it's use in "Data types à la carte"
dave at zednenem.com
Fri Dec 14 21:00:15 EST 2007
On Dec 14, 2007 4:18 PM, Felipe Lessa <felipe.lessa at gmail.com> wrote:
> If it is not, the implementation "fmap f = id" is really the only one
It pretty clear what you meant here, but it's worth noting that "fmap f =
id" is a type error.
id :: a -> a
(\Val i -> Val i) :: Val a -> Val b
These can (and, if Val is a newtype, will) be compiled to the same code, but
they don't have the same type. In particular, there is no way to unify "a ->
a" with "f a -> f b" for any f.
And yes, I'm pretty sure that's the only possible implementation for that
type which satisfies the functor laws.
Dave Menendez <dave at zednenem.com>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe