-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Greetings,
We can currently do something like
class (Num a, Eq a) = Foo a where bar :: a - a - Bool bar =
(==)
This means that our `a' has to be an instance of Num and Eq. Apologies
for a bit of an artificial example.
Is there a way however to do
Hi Mateusz,
It's not directly possible to write a class with a choice of
superclasses; as you point out, it's not really clear what that would
mean. One workaround, though it might not be sensible in practice, is
the following.
{-# LANGUAGE ConstraintKinds, GADTs #-}
First, reify the
Mateusz Kowalczyk wrote:
Is there a way however to do something along the lines of:
class Eq a = Foo a where bar :: a - a - Bool bar = (==)
class Num a = Foo a where bar :: a - a - Bool bar _ _ = False
This would allow us to make an instance of Num be an instance of Foo
or an instance of