CS7400 Machine Problem 5a: Effects and the Store: Using Monads

Out: Thursday, 10/22/09

Due: Thursday, 10/29/09

Here is the second half of the problem set. I've repeated the first two questions for reference.

  1. [10 points] Implement the language of exercise 4.22 in EOPL3. This is similar to the language discussed in section 5.5.2 of the notes. Interpret the non-terminal Expression in the grammar of exercise 4.22 to be the expressions of MUTABLE-PAIRS. Use the store implementation of interps/mutable-pairs as well.
  2. [5 points] Replace the "stupid" implementation of the store in the preceding problem with an implementation in which the store is represented as a Scheme vector mutated with vector-set!. Your interpreter should run unaltered, except for changing (require "store.scm") to (require "store-using-vector.scm") (or whatever).
  3. [10 points] Next, convert your interpreter to monadic style; that is, convert it to use the monadic interface to the store. However, your print statement should still do actual printing.
  4. [5 points] Last, incorporate print into the monad instead of doing it. In this model, printing is not done as the execution of the program proceeds. Instead, execute-program (note that I've removed the exclamation point!) will return the list of values printed by the program.

For this problem, turn in two sets of modules, in directories named mp5-3 and mp5-4.

As before, you do not need to write any specifications; we'll get to that later in the term.

There is a lot of literature out there explaining monads. Feel free to use it, and to share the sources you have found with your classmates. You can use the cs7400 mailing list for this purpose.

Last modified: Tue Nov 03 14:10:58 Eastern Standard Time 2009