{-# OPTIONS_FRONTEND -F --pgmF=currypp #-} -- Map coloring: -- The states of the great north-weste: data State = WA | OR | ID | BC deriving (Eq, Show) -- The list of these states: states :: [State] states = [WA, OR, ID, BC] -- List of state pairs with common border: adjacent :: [(State,State)] adjacent = [(WA,OR), (WA,ID), (WA,BC), (OR,ID), (ID,BC)] -- The color to use: data Color = Red | Green | Blue deriving (Eq, Show) -- Color the list of states (possible solutions): color :: State -> (State,Color) --color s = (s, Red ? Green ? Blue) color s = (s, aValue) -- Correct coloring: it is failure if two states with a common border have -- the same color: check :: [(State,Color)] -> [(State,State)] -> [(State,Color)] -- possible coloring adjacent states correct coloring check (_ ++ [(s1,c)] ++ _ ++ [(s2,c)] ++ _) (_ ++ [(s1,s2)] ++ _) = failed check'default scs _ = scs main :: [(State, Color)] main = check (map color states) adjacent