blob: 05c7c8dbf0cc39725cf29bbac51a800c64ffe794 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
module Main where
class Show a => Foo a where
op :: a -> a
newtype Moose = MkMoose () deriving (Show, Eq, Ord)
newtype Noose = MkNoose () deriving (Ord)
instance Eq Noose where
a == b = False -- Non-standard!
f :: Ord a => a -> Bool
f x = x==x
main = do print (MkNoose () == MkNoose ()) -- Eq Noose
print (f (MkNoose ())) -- via Ord Noose
print (MkMoose () == MkMoose ()) -- Eq Moose
print (f (MkMoose ())) -- via Ord Moose
putStrLn (show (MkMoose ())) -- Should not use the show () method
|