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
.mli
filessrc/fpse_monad.mli
,src/state_monad.mli
, andsrc/stack_monad.mli
. Look at the files in this order, and implement an appropriately named.ml
file for each of them.- Do not edit the
.mli
files. You will not submit them. - Note you may not use
Core
insrc/fpse_monad.ml
. You will not submit adune
file forsrc/
, so you cannot add any libraries to what is in the givendune
file.
- Do not edit the
- A library using your
Stack_monad
module is insrc/main.ml
. See that file and follow the instructions to complete the implementation. - There is an empty
test/tests.ml
in which you will put your tests.- You won’t be graded on your tests.
- You need to fill in the
test/dune
file.
- Answer a quick discussion question in
discussion.txt
.
Submission and Grading
- As usual, run a final
dune clean; dune build
and then upload_build/default/assignment7.zip
to 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 instead of cheating with mutation.