[Haskell-beginners] help on writing a typeclass
Imants Cekusins
imantc at gmail.com
Sat Jun 4 07:29:03 UTC 2016
would this work:
{-# LANGUAGE MultiParamTypeClasses, InstanceSigs #-}
module Mdk where
data C a b = Ab a b | Ba b a
class Mdk a b where
mdk::a -> b -> C a b
instance (Eq a, Eq b) => Eq (C a b) where
(==)::C a b -> C a b -> Bool
(==) (Ab a1 b1) (Ab a2 b2) = a1 == a2 && b1 == b2
(==) (Ab a1 b1) (Ba b2 a2) = a1 == a2 && b1 == b2
(==) (Ba b2 a2) (Ab a1 b1) = a1 == a2 && b1 == b2
(==) (Ba b2 a2) (Ba b1 a1) = a1 == a2 && b1 == b2
?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160604/d280c62a/attachment.html>
More information about the Beginners
mailing list