Question: SML coding: Given: Define type 'a env as an abbreviation for a function type, and define exception NotFound, both as follows: type 'a env =

SML coding:
Given: Define type 'a env as an abbreviation for a function type, and define exception NotFound, both as follows:
type 'a env = string -> 'a
exception NotFound of string
Define these functions
val emptyEnv : 'a env = (* ... *)
val bindVar : string * 'a * 'a env -> 'a env = (* ... *)
val lookup : string * 'a env -> 'a = (* ... *)
such that you can use 'a env for a type environment or a value environment. On an attempt to look up an identifier that doesnt exist, raise the exception NotFound. Dont worry about efficiency.
Lastly define a function
val isBound : string * 'a env -> bool
that tells if a name is bound in the environment.

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!