Claus Reinke wrote:
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

Such an fmap will not have the required type

  (a -> b) -> f a -> f b

Consider "fmap even". Then a=Int, b=Bool, x::f Int,
(fmap even x)::f Bool, type error since you assumed fmap even x = x !

Ciao, Janis.

--
Dr. Janis Voigtlaender
http://wwwtcs.inf.tu-dresden.de/~voigt/
mailto:[EMAIL PROTECTED]

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

Reply via email to