module Lattice where

class (Eq a, Show a) => Lattice a where
  label_top :: a
  label_bottom :: a
  label_join :: a -> a -> a
  label_meet :: a -> a -> a
  label_leq :: a -> a -> Bool

data TriLabel = LOW | MEDIUM | HIGH 
		deriving (Eq, Show)

instance Lattice TriLabel where
  label_top = HIGH
  label_bottom = LOW
  label_join x y=if x `label_leq` y then y else x
  label_meet x y=if x `label_leq` y then x else y
  label_leq LOW _ = True
  label_leq MEDIUM LOW = False
  label_leq MEDIUM _ = True
  label_leq HIGH HIGH = True
  label_leq HIGH _ = False

