projects
/
yorgey.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
305e0c2
)
hw5: exercise 3
author
Ramakrishnan Muthukrishnan
<ram@rkrishnan.org>
Sun, 21 Dec 2014 12:07:24 +0000
(17:37 +0530)
committer
Ramakrishnan Muthukrishnan
<ram@rkrishnan.org>
Sun, 21 Dec 2014 12:07:24 +0000
(17:37 +0530)
hw5/Calc.hs
patch
|
blob
|
history
diff --git
a/hw5/Calc.hs
b/hw5/Calc.hs
index ef4fd2e2542a1d2ccf8cbb22ed01e335d2f42b74..46f782018c617ae69a0bb440c77af5a753d1cbed 100644
(file)
--- 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