I\'m trying to write some Haskell code in which there are multiple data types, each of which can have multiple implementations. To do this, I define each data type as a
There's no really good way to do this; the best practice is to define some constants like
plusA, minusA :: (A a, Num x) => a x -> a x -> a x
which makes writing the Num
instances more mechanical after you have an A
instance:
instance A Foo where ...
instance Num x => Num (Foo x) where
(+) = plusA
(-) = minusA