Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Do you talk about them as if they are giving you gifts?

Answered: 1 week ago

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago