Using Monads - IO TH and Parsec

Due Thursday, Sept 26th @ 9 am

From this assignment, students will show...

functional programming - recall

...through composing the standard library functions using the Monad's Typeclass methods.

codegen and metaprogramming - recall

...through implementing Template Haskell functions for NCurry and NCompose.

frontend design - recall

...through implementing a Parsec Parser for a prefix arithmetic language.

Note: For recall learning objectives, please tell me what skill you had to apply again and where it was originally applied.

Note: There are more opportunities for gaining Recognition learning objectives in this assignment if you apply these techniques onto similar problems that have the same pattern that I point out or that you find yourself.

Let's begin

  1. Pull the latest Exemplars Github Repo
  2. Follow the instructions in app/io1/Main.hs and app/io2/Main.hs
  3. Implement an N-arity curry function in src/NCurry.hs that passes the tests in tests/ncurry/Main.hs
  4. Implement an N-arity compose function in src/NCompose.hs that passes the tests in tests/ncurry/Main.hs
  5. Implement the parsePrefix monadic parser in src/Arith.hs that passes the tests in tests/arith/Main.hs
  6. Finish the usual material for your META.md

Step-by-step instruction

The Following videos are available as a Playlist at this link

Context and Motivation

TL;DW: The components of the language design pipeline for desinging DSLs in this class will be implemented using some common monads in Haskell. IO for app and library code, Q for metaprogramming, and ParsecT (Parser) for lexing and parsing concrete syntax. The assignment that follows are small exercises that touch on each of these. And in a later assignment, we will be putting these pieces together.

Some notes about the template project:

TL;DW:

The IO Monad

Note: Feel free to start the rest of the homework first, and if you are confused, then look at these slides and/or this video. It is long, but detailed. I suggest looking through the slides first until you find the slide relevant to what you want to know, and then find the corresponding part in the lecture video. Lecture slides

TL;DW

Homework Description

TL;DW

Template Haskell - Q Monad

TL;DW

Parser (ParsecT)

TL;DW

(Optional) Recognition Points

Technically, any part of any homework is optional if you already have the learning objective for that part. But alas...

Should you want to do more or achieve deeper learning objectives, I highly encourage it.

Consider the list of small word problems below for which I believe a IO, TH, or Parser Monadic implementation could help. Sketch a solution and a short description of what design pattern or skill from this homework you Recognized in the problem for advanced points.

META.md

META.md should include
  1. Your name.
  2. Your utln.
  3. How much time you spent on this assignment.
  4. The witness "proof" for how you earned each learning objective with a note about recall for recall objectives and what problem you recognized in the recognization objectives.

Please Submit

Contents to be submitted

Method of submission

Please commit your changes in the hw06-1-using directory of your private repo and push them to the remote server before 9 am.