[Haskell-beginners] Structural restrictions in type constructor

Rein Henrichs rein.henrichs at gmail.com
Tue Jun 23 20:33:55 UTC 2015


FYI, Data.Map uses an Ord instance for keys, not an Eq instance.

On Tue, Jun 23, 2015 at 1:15 PM Imants Cekusins <imantc at gmail.com> wrote:

> > alter its Eq => definition
>
> module MatchTuple (MyP) where
>
> data MyP t = MyP(t,t) deriving Show
> instance Eq t => Eq (MyP t)  where
>    (==) = match
>
>
> match::Eq t =>  MyP t-> MyP t -> Bool
> match (MyP(x1,x2)) (MyP(x3,x4))
>    | x1 == x3 &&  x2 == x4 = True
>    | x1 == x4 &&  x2 == x3 = True
>    | otherwise = False
>
>
> ?
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150623/5178f9be/attachment.html>


More information about the Beginners mailing list