[Haskell-cafe] FGL instance constraint

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Sat May 1 02:56:19 EDT 2010


Jason Dagit <dagit at codersbase.com> writes:

> On Fri, Apr 30, 2010 at 11:30 PM, Jason Dagit <dagit at codersbase.com> wrote:
> Looking over this real quick, I think the Graph class should be changed to
> mention a and b:
>
> class Graph (gr a b)  where ...

Won't work: you need to specify that gr has kind * -> * -> *; this is
exactly the same as how Functor, Monad, etc. are defined.

>
> Then your instances would be able to mention constraints:
>
> instance Cls a => Graph (GrB a b) where ...
>
> Why wasn't the Graph class designed this way?  My guess:  It was probably a
> decision that predated multiparameter type classes.

That's not an MPTC (it would be more like "class Graph gr a b" if it
was) and doesn't matter in this case anyway.

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


More information about the Haskell-Cafe mailing list