From: Ramakrishnan Muthukrishnan Date: Sun, 21 Dec 2014 12:07:24 +0000 (+0530) Subject: hw5: exercise 3 X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/module-simplejson._speedups.html?a=commitdiff_plain;h=04036d0605e95c06f5d6dea11c2618267c059550;p=yorgey.git hw5: exercise 3 --- 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