module Store where import List((\\)) data Store a b = Store [(a, b)] empty :: Store a b empty = Store [] get :: Eq a=> Store a b-> a-> Maybe b get (Store s) a = get' s where get' [] = Nothing get' ((b, v):s) = if a == b then Just v else get' s upd :: Eq a=> Store a b-> a-> b-> Store a b upd (Store s) a v = Store (upd' s) where upd' [] = [(a, v)] upd' ((b, w):s) = if a == b then (a, v):s else (b,w): upd' s instance (Show a, Show b)=> Show (Store a b) where show (Store s) = show s instance (Eq a, Eq b)=> Eq (Store a b) where Store s1 == Store s2 = null (s1 \\ s2) && null (s1 \\ s2)