Theory and Design of PL (CS 538)
February 12, 2020
aa isa is Bool then … if a is Int then …toString :: a -> String(==) :: a -> a -> Bool(<) :: a -> a -> Boolclass Eq a where
(==) :: a -> a -> Bool
(/=) :: a -> a -> Bool
x == y = not (x /= y)
x /= y = not (x == y)== or /= is enoughclass Eq a => Ord a where
(<) :: a -> a -> Bool
(>) :: a -> a -> Bool
(<=) :: a -> a -> Bool
(>=) :: a -> a -> BoolOrd needs to satisfy Eq-- Can be applied as long as type `a` is an instance of `Eq a`
elem :: Eq a => a -> [a] -> Bool
elem x [] = False
elem x (y:ys) = (x == y) || elem x ys
-- `(==)` function from `Eq` typeclassShow: can be converted to a stringRead: can be converted from a stringEnum: can be enumeratedBounded: has max and min elementNum: things generalizing integersclass (Eq a, Show a) => Num a where
(+) :: a -> a -> a
(-) :: a -> a -> a
(*) :: a -> a -> a
abs :: a -> a -- absolute value
negate :: a -> a -- negation
signum :: a -> a -- sign: +1 or -1
fromInteger :: Integer -> aIntegral, FloatingEq typeclass, …