Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started