Template Haskell - Lab
From doing these activities students will
- Dissect an artifact of TH programming at the level we expect for the course
- Reason about problems similar to the ones presented in the TH paper
- Have the process of intractively programming with TH modeled for them
In class Announcements - 5 min (9:00 ~ 9:05)
Warm-up activity - 5 min (9:05 ~ 9:10)
On a piece of paper, answer any or all of the following questions:
"What do you think is the most common question students in the class have right now?"
"What do you think is the most pressing question students in the class have right now?"
"What do you think is the most interesting question students in the class have right now?"
Groups and Roles
Scribes
- Take notes for your group to contribute to the wiki page for the discussion
- A head scribe will go and write a summary on that page for an extra credit point
Managers
- Keep track of time
- Make a role ticket on the Reading repo for everyone in your group
Ambassadors
- Presents the unified thoughts of their group
- Talks with instructors at the end about meta class management
Small group discussion - 35 min (9:10 ~ 9:45)
At pseudo-random, pick one of the following three metaprograms to try and implement, using This exemplar as a guide. Especially:
this implementation of sel
- update which, given two numbers at compile time n and m, produces a lambda expression that takes an n-tuple and an element and returns the n-tuple with the mth member replaced by the element.
- delete which, given two numbers at compile time n and m. produces a lambda expression that takes an n-tuple and returns an n-minus-1-tuple with the mth member removed.
- swap which, given three numbers at compile time n, i, and j produces a lambda expression that takes an n-tuple and returns an n-tuple with the ith and jth elements swapped.
Your discussion can be at the cursory level. You don't have to get the syntax perfect, as we will be fleshing them out interactively in the big group discussion.
If you finish early, discuss how you would approach N-Curry, the metaprogram which, when given a number n, takes in an uncurried function that expects a tuple of n arguments and returns a curried function.
Useful Template Haskell documentation as it is currently implemented
Large group discussion - 25min (9:45 ~ 10:10)
Matthew will live code your solutions.
Cool-down activity - 5 min (10:10 ~ 10:15)
All scribes will get together to start their wiki write up to be finished
at latest a week from today.
All managers will get together and make tickets for the course.
This can include the tickets from their group discussions as mentioned above,
a ticket to follow up on the scribe write up, and any other issues they
think will be helpful.
All ambassadors will get together with Matthew and Kathleen and discuss how they think
the day went, how they think the pacing went, what they are looking forward to, any
worries they might have about the class, etc.
Class Dismissed
Monday's a DSL paper and Wednesday is coding with the IO monad.