[Haskell-cafe] Functions of type foo :: f a -> g a

C. McCann cam at uptoisomorphism.net
Tue May 11 14:38:39 EDT 2010


On Tue, May 11, 2010 at 2:06 PM, John Meacham <john at repetae.net> wrote:
> A better way might be
>
> class (Functor f, Functor g) => FunctorPair f g where
>        transformFunctor :: f a -> g a
>
> though, I am not sure what your use is, there isn't an obvious instance
> to me, but I don't know what your motivating task is.

Furthermore, to select an instance at this point both Functors must be
known in context of use, which exhausts pretty much the entire
informational content of the instance--raising the question of what
benefit is drawn from a type class at all, as opposed to simply
passing around functions of type "f a -> g a" as needed. Consider that
fmap doesn't require a multi-parameter type class for each pair a, b,
it just takes a function (a -> b).

The only way a type class would make sense here, I think, is with a
fundep uniquely determining a particular natural transformation based
on one of the Functors, at which point I'm not sure that the concept
of "natural transformation" is what you're actually trying to model.

- C.


More information about the Haskell-Cafe mailing list