Designing and Instantiating Monads
Due Wednesday, Oct 2nd @ 9 am
From this assignment, students are likely to show...
functional programming - recognition
by recognizing what functional programming patterns to use in designing the Logger Monad.
Let's begin
- Pull the latest Exemplars Github Repo
- Optional META.md
Step-by-step instruction
Playlist of all the videos
Context and Motivation
TL;DW:
- This is the last tutorial assignment for this course
- Rest of the coding assignments will be applying the tools we have learned to achieve our goals
- The tasks for this assignment will model how you can design your own runtime system and library as a monad to support an evaluator for your language
- EDIT: We will do the quasiquoter together in class
Recall: An evaluator for our Arith language
TL;DW:
- Evaluating arithmetic might result in an error when we divide by zero.
- We can model the side effects of using an algebraic data type
- Unwrapping and wrapping the ADT is tiresome
Example: The Hopefully Monad
Slides that cover this topic
TL;DW:
- We want to map pure functions over non-error'd values, so we define a Functor instance for Hopefully
- We want to be able to accumulate errors that occur in unordered computation, so we define an Applicative instance for Hopefully
- We want to stop performing ordered computation when an argument encounters an error, so we define a Monad instance for Hopefully
- Now we can rewrite our evaluator with do-notation
Your turn: The Logger Monad
TL;DW:
META.md
META.md should include
- Your name.
- Your utln.
- How much time you spent on this assignment.
- The witness "proof" for how you earned each learning objective with a note of what design pattern you recognized in the recognization objectives.
Please Submit
Contents to be submitted
- Your copy of hw08-1-design-monads.
- META.md
Method of submission
Please commit your changes in the hw08-1-design-monads directory of your private repo and push them to the remote server before 9 am.