Question
ould you please solve the following question in Haskell language programming. Extend the abstract syntax tree data type Expr to add new operations Neg (negation),
ould you please solve the following question in Haskell language programming.
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started