Re: [Haskell-cafe] Questions about the Functor class and it's use in "Data types à la carte"

Benja Fallenstein benja.fallenstein at gmail.com
Fri Dec 14 21:44:17 EST 2007


On Dec 15, 2007 3:15 AM, Ryan Ingram <ryani.spam at gmail.com> wrote:
>
> On 12/14/07, David Menendez <dave at zednenem.com> wrote:
> > And yes, I'm pretty sure that's the only possible implementation for that
> type which satisfies the functor laws.
>
> Lets just prove it, then; I'm pretty sure it comes pretty easily from the
> free theorem for the type of fmap.
...
> Now, first note that since we cannot make any choices based on the type of
> f, there's no way for f to be relevant to the result of fmap; we have no way
> to get something of type "a" besides _|_ to pass to f, and no use for things
> of type "b".

Hmmm. Something about that ticks off my "don't play fast and loose
with bottom" detector.

data Val a = Val Int

instance Functor Val where
    fmap f (Val x) = f `seq` Val x

:-)

- Benja


More information about the Haskell-Cafe mailing list