Question: Conider the type checker for a simple expression language data Type = Int | Bool | TypeError deriving ( Eq , Show ) tc ::

Conider the type checker for a simple expression language
data Type = Int | Bool | TypeError
deriving (Eq,Show)
tc :: Expr -> Type
tc (N i)= Int
tc (Plus e e')| tc e==Int && tc e'==Int = Int
tc (Equal e e')| tc e==Int && tc e'==Int = Bool
| tc e==Bool && tc e'==Bool = Bool
tc (Not e)| tc e==Bool = Bool
tc _= TypeError
Suppose you want to add type checking for boolean Or (Or expr expr) of two expressions that must evaluate to booleans. Select the appropriate line of code.
Group of answer choices
tc (Or e e')| tc e==Bool && tc e'==Bool = Bool
tc (Or e e')| tc e==Bool or tc e'==Bool = Bool
tc (Or e e')| tc e==Bool or tc e'==Bool
tc (Or e e')| tc e==Bool && tc e'==Bool = Int
None of these

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!