[Haskell-cafe] Restricted type classes

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Mon Sep 6 23:58:24 EDT 2010


2010/9/7 Gábor Lehel <illissius at gmail.com>:
> *That said*, I actually have nothing at all against splitting the 'a
> -> f a' method out into a separate class if you think it's useful,
> whether you call it Pointed or something else. (And `class (Pointed f,
> Functor f) => PointedFunctor f` is sort of cute.)

It might be cute, but until we get class aliases [1] this results in
yet another class to make your data type an instance of, and what's
more it's one that doesnt' even give you anything.

I think it makes much more sense to have Functor, Pointed and
"(Functor f, Pointed f) => Applicative f" rather than a useless
intermediary class.  If, however, we could get class aliases _for
free_ (i.e. something like "class alias PointedFunctor f = (Functor f,
Pointed f)" for which all instances of Functor and Pointed are
automatically instanced of PointedFunctor), then I can see that as
being something nice to have.

[1]: http://www.haskell.org/haskellwiki/Context_alias

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com


More information about the Haskell-Cafe mailing list