Question: -Could you please solve the following question in Haskell. Extend the abstract syntax tree data type Expr to add new operations Neg (negation), Min (minimum),
-Could you please solve the following question in Haskell.
Extend the abstract syntax tree data type Expr to add new operations Neg (negation), Min (minimum), Max (maximum), and Exp (exponentiation).
data Expr = ...
| Neg Expr
| Min Expr Expr
| Max Expr Expr
| Exp Expr Expr
...
deriving Show
Then extend the eval function (in the EvalExpr module) to add these new operations with the following informal semantics:
Neg e negates the value of e Neg (Val 1) is (Val (-1))
Min l r returns the smaller value of l and r
Max l r returns the larger value of l and r
Exp l r raises l to the poewr r
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
