[Haskell-cafe] Families of type classes

Fraser Wilson blancolioni at gmail.com
Sun Nov 6 09:29:52 EST 2005

On 11/6/05, Klaus Ostermann <ostermann at informatik.tu-darmstadt.de> wrote:
> instance Node Person where
> isConnectedTo g n (p1,p2) = (p1 == n) || (p2 == n)

At this point, isConnectedTo knows nothing about the third argument except
that it is an edge, and there's no reason to think that an Edge is a tuple.
All you can say is that there are two functions, n1 and n2, which extract
the nodes of the edge. Use those instead, for example

isConnectedTo g n p = n == n1 p || n == n2 p

 Couldn't match the rigid variable `e' against `(a, b)'
> `e' is bound by the type signature for `isConnectedTo'
> Expected type: e
> Inferred type: (a, b)
> When checking the pattern: (p1, p2)
> In the definition of `isConnectedTo':
> isConnectedTo g n (p1, p2) = (p1 == n) || (p2 == n)

Hopefully this error makes more sense now. It's saying that it expected
something of type 'e', but it found a tuple.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org//pipermail/haskell-cafe/attachments/20051106/fa403d36/attachment.htm

More information about the Haskell-Cafe mailing list