From 04036d0605e95c06f5d6dea11c2618267c059550 Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan Date: Sun, 21 Dec 2014 17:37:24 +0530 Subject: [PATCH] hw5: exercise 3 --- hw5/Calc.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw5/Calc.hs b/hw5/Calc.hs index ef4fd2e..46f7820 100644 --- a/hw5/Calc.hs +++ b/hw5/Calc.hs @@ -18,3 +18,13 @@ evalStr :: String -> Maybe Integer -- Just e -> Just (eval e) -- Nothing -> Nothing evalStr s = fmap eval (parseExp Lit Add Mul s) + +class Expr a where + lit :: Integer -> a + add :: a -> a -> a + mul :: a -> a -> a + +instance Expr ExprT where + lit = Lit + add = Add + mul = Mul -- 2.37.2