import Test.Prop
data State = OR | WA | ID | BC deriving (Show, Eq)
states :: [State]
states = [OR, WA, ID, BC]
type Adiacency = [(State, State)]
adiacency :: Adiacency
adiacency = [(OR,WA),(OR,ID),(WA,ID),(WA,BC),(ID,BC)]
data Color = Red | Green | Blue deriving (Show, Eq)
type ColoredMap = [(State,Color)]
coloredmap :: ColoredMap
coloredmap = map (\x -> (x,pick)) states
prop_coloredmap_example = coloredmap ~> [(OR,Red),(WA,Green),(ID,Green),(BC,Blue)]
prop_coloredmap_count = coloredmap # 3*3*3*3
pick :: Color
pick = Red ? Green ? Blue
prop_pick_example = pick ~> Green
prop_pick_count = pick # 3
check :: ColoredMap -> Adiacency -> ColoredMap
check (_++[(s1,c)]++_++[(s2,c)]++_) (_++[(s1,s2)]++_) = failed
check'default c _ = c
prop_check_fail = failing (check [(OR,Red),(WA,Green),(ID,Red),(BC,Blue)] adiacency)
prop_check_succeed = check x adiacency -=- x where x = [(OR,Green),(WA,Red),(ID,Blue),(BC,Green)]
main :: ColoredMap
main = check coloredmap adiacency
prop_main = main <~> (
[(OR,Red),(WA,Green),(ID,Blue),(BC,Red)] ?
[(OR,Red),(WA,Blue),(ID,Green),(BC,Red)] ?
[(OR,Green),(WA,Red),(ID,Blue),(BC,Green)] ?
[(OR,Green),(WA,Blue),(ID,Red),(BC,Green)] ?
[(OR,Blue),(WA,Red),(ID,Green),(BC,Blue)] ?
[(OR,Blue),(WA,Green),(ID,Red),(BC,Blue)]
)