Homework # 10
due November 15

Reading

Please read Chapters 20 and 21 in your textbook.

Problems

Please do the following problems

Please check your answers against the solutions in the book. Do not turn in your answers.

Implementation

Combine the checkers fullequirec and fullref in a single implementation that handles types such as:


Counter = Rec S . { get : S -> Nat, 
                    set : S -> Nat -> Unit, 
                    inc : S -> Unit };

counterClass = 
   lambda rep: {x: Ref Nat}.
          {get = lambda s:Counter . !(rep.x),
	   set = lambda s:Counter . lambda n:Nat . (rep.x) := n,
           inc = lambda s:Counter . (s.set) s (succ ((s.get) s))}
	as Counter;

makeCounter =
  lambda i:nat . counterClass {x = (ref i)};
Put this combined code in a subdirectory fullequirecref in your homework10 folder.

Discussion

Can you typecheck your answer to Question 4.3 of Homework #9 (object.f) now that you have recursive types? (Of course, you will need to fix/specify the types.) Why or why not? What happens?

About this document



John Tang Boyland
2005-11-08