I'm working through the interesting paper "Data type à la carte" and
am confused by the Functor instance for Val. I think this stems from
some confusion of mine regarding the Functor class in general.

The Functor instance I'm confused about is:
    instance Functor Val where
        fmap f (Val x ) = Val x

where Val is defined as:
    data Val e = Val Int

Is this the only valid Functor instance for the Val type? Even though
I'd, naively, expect the Functor instance to look like:
    instance Functor Val where
        fmap f (Val x) = Val (f x)

I suspect that would not work out due to the type of the Val
constructor. Is this correct?

The reason I find all this odd is because I'm not sure how the type
class Functor relates to the category theory concept of a functor. How
does declaring a type constructor to be an instance of the Functor
class relate to a functor? Is the type constructor considered a
functor?

Any help would be, of course, greatly appreciated.

-Corey O'Connor
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to