module EvalIntExpr ( evalIntExpr, testEvalIntExpr, IntExpr(..) ) where import…
- User
module EvalIntExpr ( evalIntExpr, testEvalIntExpr, IntExpr(..) ) where
import Test.QuickCheck
-- an IntExpr is an expression-tree over integers data IntExpr = Leaf Int | Add IntExpr IntExpr | Sub IntExpr IntExpr | Mul IntExpr IntExpr | Uminus IntExpr deriving (Eq, Show)
-- evalIntExpr returns the Int result of evaluating the IntExpr -- expression-tree given by its argument. evalIntExpr :: IntExpr -> Int evalIntExpr _ = error "TODO"
testEvalIntExpr = do print "******* test evalIntExpr"
quickCheck evalIntExpr (Leaf 42) == 42 quickCheck evalIntExpr (Add (Leaf 33) (Leaf 22)) == 55 quickCheck evalIntExpr (Sub (Leaf 33) (Leaf 22)) == 11 quickCheck evalIntExpr (Mul (Leaf 31) (Leaf 4)) == 124 quickCheck evalIntExpr (Uminus (Leaf 33)) == (-33) quickCheck evalIntExpr (Mul (Leaf 4) (Sub (Add (Leaf 3) (Uminus (Leaf 33))) (Leaf 20))) == (-200)
- Assistant
Your module is well-structured for defining, evaluating, and testing operations on integer expressions represented as trees. To achieve the objectives of your tasks, you'll need to implement . Below, I'll provide the implementation for along with slight improvements and typo corrections in your test expressions. Let's fill in the missing part:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.