module Types where import Finite import Pretty import Text.PrettyPrint -- The class of conjoinable types (on the handout it is called Conjoin -- rather than Conjoinable) class Conjoinable c where conjoin :: c -> c -> c instance Conjoinable Bool where conjoin x y = x && y instance (Conjoinable b) => Conjoinable (a -> b) where conjoin f g x = conjoin (f x) (g x) -- The type of binary trees data Tree a = Leaf a | Branch (Tree a) (Tree a) deriving (Show) same (Leaf x) (Leaf y) = True same (Branch l1 r1) (Branch l2 r2) = same l1 l2 && same r1 r2 same (Leaf x) (Branch l2 r2) = False same (Branch l1 r1) (Leaf y) = False