Assignment 7: Monads and more functors
In this assignment you will write a functor and a monad module, and then you’ll use the module to refactor some stateful OCaml code to use a state monad.
The file structure
- Use this zip file for your assignment.
- Provided are three
.mlifilessrc/monad.mli,src/state_m.mli, andsrc/stack_m.mli. Look at the files in this order, and implement an appropriately named.mlfile for each of them.- Do not edit the
.mlifiles. You will not submit them.
- Do not edit the
- A library using your
Stack_mmodule is insrc/main.ml. See that file and follow the instructions to complete the implementation. - There is an empty
test/tests.mlin which you will put your tests.- You won’t be graded on your tests.
- You need to fill in the
test/dunefile to run your tests.
- Answer a quick discussion question in
discussion.txt.
Submission and Grading
- As usual, run a final
dune clean; dune buildand then upload_build/default/assignment7.zipto Gradescope. - You will be graded with an autograder and on your discussion question.
- We will check that you actually used the monad in your implementation.