ex_class.hs revision b87efd3db0d2dc41615ea28669faf80fc1b48d56
{- |
Module : $EmptyHeader$
Description : <optional short description entry>
Copyright : (c) <Authors or Affiliations>
License : GPLv2 or higher
Maintainer : <email>
Stability : unstable | experimental | provisional | stable | frozen
Portability : portable | non-portable (<reason>)
<optional description>
-}
module SimpleClass where
data Color a = Red a | Blue a
data MyList a = MyNil | MyCons a (MyList a)
data MPList a b = MPNil | MPCons a b (MPList a b)
myEqual :: Eq a => a -> a -> Bool
myEqual x y = if x == y then True else False
instance Eq a => Eq (Color a)
instance Eq a => Eq (MyList a)
class Joker a where
methodOne :: a -> a -> Bool
methodTwo :: a -> Bool -> Color a
instance (Joker a, Eq a) => Joker (Color a) where
methodOne = myEqual
instance (Joker a, Eq a) => Joker (MyList a) where
methodOne = myEqual
methodTwo x y = if y == True then Red x else Blue x
instance (Joker a, Eq a, Eq b) => Joker (MPList a b)