Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the part of Type Inference type op = Add | Sub | . . . type var = string type expr = |

This is the part of Type Inference

type op = Add | Sub | . . . type var = string type expr = | Int of int | Bool of bool | String of string | ID of var | Fun of var * expr | Not of expr | Binop of op * expr * expr | If of expr * expr * expr | FunctionCall of expr * expr | Let of var * bool * expr * expr | Pair of exper * expr

type typeScheme = | TNum | TBool | TStr | T of string | TFun of typeScheme typeScheme | TPair of typeScheme typeScheme

We assume the parser has also been extended so it can parse a pair in the syntax {1, 2} as an abstract syntax tree Pair(1, 2). For example, the extended MicroCaml language allows you to write a program as follows:

Let rec f x y = if x then { f y , y} else { y , f x }

We also extended typeScheme to support pair types. A pair type for Pair(1, 2) is in the shape of {1 2} where 1 is the type of 1 and 2 is the type of 2. For example, the type of the expression {1, " hello "} is {int string } or TPair (TNum, TStr).

Q) Write down the type of

Let rec f x y = if x then { f y , y} else { y , f x }

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Database Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

More Books

Students also viewed these Databases questions

Question

=+ (b) Show that X' and Y' are dependent but uncorrelated.

Answered: 1 week ago

Question

What is the cerebrum?

Answered: 1 week ago