fundeps question
Ashley Yakeley
ashley@semantic.org
Sun, 15 Dec 2002 17:43:46 -0800
At 2002-12-14 15:27, nalexand@gianther.hypbus.com wrote:
>I define
>
>class Mul a b c | a b -> c, b a -> c where mul :: a -> b -> c
The two constraints are identical. Each one says "given a and b, you have
c".
What you want is essentially this:
class (Mul b a c) => Mul a b c where
mul :: a -> b -> c
mul a b = mul b a
...but that's not allowed as superclass contexts cannot be circular.
>I want
>
>instance (Mul a b c) => Mul b a c where mul x y = mul y x
This will overlap with any other "Mul" instance. Instance declarations
cannot be made overridable the way functions in OOP languages can be:
each instance declaration must have an entirely separate domain.
--
Ashley Yakeley, Seattle WA