[Haskell-cafe] Unique functor instance

Claus Reinke claus.reinke at talk21.com
Tue Nov 25 08:37:47 EST 2008


> Luke Palmer wrote:
>> I've been wondering, is it ever possible to have two (extensionally)
>> different Functor instances for the same type?  I do mean in Haskell;
>> i.e. (,) doesn't count.  I've failed to either come up with any
>> examples or prove that they all must be the same using the laws.
> 
> For "not-too-exotic" datatypes, in particular for algebraic data types
> with polynomial structure (no exponentials, embedded function types, and
> other nasties), I would conjecture that indeed there is always exactly
> one Functor instance satisfying the identity and composition laws.

Are identity and composition sufficient to guarantee that the
mapped function is actually applied?

    instance Functor f where fmap _ x = x

    fmap id fx ~ fx ~ id fx
    fmap f (fmap g fx) ~ fmap f fx ~ fx ~ fmap (f . g) fx

Claus



More information about the Haskell-Cafe mailing list