[Haskell-cafe] FGL instance constraint

Kevin Quick quick at sparq.org
Sat May 1 16:32:07 EDT 2010


On Sat, 01 May 2010 01:01:47 -0700, Sebastian Fischer <sebf at informatik.uni-kiel.de> wrote:

>
> On May 1, 2010, at 8:08 AM, Ivan Lazar Miljenovic wrote:
>
>>> * I can't redefine the Graph methods to introduce the (Cls a)
>>> constraint [reasonable]
>>
>> Not sure if you can.
>
> I think Kevin means that he cannot change the signature of the methods
> in the Graph class because those are defined in the FGL package.

Mostly.

If I was able to redefine the method to add the class constraint in *my* code, that would be "what I wanted" but clearly wrong from the general type perspective: once defined it should not be possible to redefine.  I was more trying to indicate that I'd been flailing around and trying everything, even things that make me look stupid.  :-)

>
>> You're putting the constraint in the wrong places: put the "(Cls a)
>> => "
>> in the actual functions where you need it.
>
> Those seem to be the methods of the Graph class, where he can't place
> the constraints. Kevin may have a version of  makeGraph  with
> additional constraints but cannot use it to to define a  Graph
> instance.

Exactly.  I posted a separate response with more details, but this is my problem.  Actually, I'm even struggling defining the "empty" method of Graph.

-- 
-KQ


More information about the Haskell-Cafe mailing list