lit = Lit
add = Add
mul = Mul
+
+reify :: ExprT -> ExprT
+reify = id
+
+instance Expr Integer where
+ lit = id
+ add = (+)
+ mul = (-)
+
+instance Expr Bool where
+ lit x | x <= 0 = False
+ | otherwise = True
+ add = (||)
+ mul = (&&)
+
+newtype MinMax = MinMax Integer deriving (Show, Eq)
+
+instance Expr MinMax where
+ lit = MinMax
+ add (MinMax x) (MinMax y) = MinMax (max x y)
+ mul (MinMax x) (MinMax y) = MinMax (min x y)
+
+newtype Mod7 = Mod7 Integer deriving (Show, Eq)
+
+instance Expr Mod7 where
+ lit x = Mod7 (x `mod` 7)
+ add (Mod7 x) (Mod7 y) = Mod7 ((x+y) `mod` 7)
+ mul (Mod7 x) (Mod7 y) = Mod7 ((x*y) `mod` 7)