mirror of
https://github.com/sdiehl/write-you-a-haskell.git
synced 2024-09-11 19:47:31 +03:00
15 lines
235 B
Haskell
15 lines
235 B
Haskell
data T
|
|
= Add T T
|
|
| Mul T T
|
|
| Div T T
|
|
| Sub T T
|
|
| Num Int
|
|
|
|
eval :: T -> Int
|
|
eval x = case x of
|
|
Add a b -> eval a + eval b
|
|
Mul a b -> eval a + eval b
|
|
Div a b -> eval a + eval b
|
|
Sub a b -> eval a + eval b
|
|
Num a -> a
|