





































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






































Think of S as a table. In this table we look up the types of simple objects like variables. So (S x) = t means that when we look up the type of x we find the type t
For Primitives, like constants, we just know their types.
Note how the domain of the function must have the same type as the actual argument.,
Assignment and If expressions
S |- x : t ref S |- y : t
S |- x := y : unit
S |- x : bool S |= s1 : t
S |- s2 : t
S |- if x then s1 else s2 : t
fun typeeq (x,y) =
case (x,y) of
(Void,Void) => true
| (Int,Int) => true
| (Char,Char) => true
| (Bool,Bool) => true
| (Arrow(d1,r1),Arrow(d2,r2)) => typeeq(d1,d2) andalso
typeeq(r1,r2)
| (Product(ss),Product(ts)) => (listeq ss ts)
| (,) => false
and listeq (x::xs) (y::ys) =
typeeq(x,y) andalso listeq xs ys | listeq [] [] = true | listeq _ _ = false Note we need mutually recursive functions
Types