Short version: Where can I find highly varying, small or medium-sized exercises and examples on the use, identification and instance declaration of Haskell’s abstractions such as applicatives, monads, monoids, foldables, transversables and monad transformers?
I have identified a serious lack of small to medium-sized exercises on Haskell’s “higher abstractions,” such as applicatives, monads, monoids, foldables, transversables and monad transformers. When studying, say, the use of higher-order functions such as
foldr, many materials contain a good set of exercises, starting from simple ones and proceeding to varying levels of challenge. When it comes to the “higher abstractions,” the situation is, in my humble opinion, extremely poor, even after combing through many sources and trying to extract everything that is available.
To help the student understand and appreciate these abstractions I would expect to see highly varying, small to medium-sized exercises. These exercises should make the student, among other things,
- use these abstractions
- write instances of these abstractions
- identify cases where these abstractions could be defined and used
- identify cases where these abstractions can not be defined and used
- compare the use of these abstractions to not using them.
As background information, my two favourite materials are Hutton’s Programming in Haskell (2nd ed.) for a solid basis and Allen’s and Moronuki’s Haskell Programming from First Principles for some of their material on more advanced topics.
While Hutton’s Programming in Haskell is a superb text for the basics, a good example of what is missing is its chapter “Foldables and friends” on monoids, foldables and transversables. The exercise set does not contain a single exercise that would make the student practice the use of these abstractions. It does not contain a single exercise of identifying the existence of these abstractions in some domain.
These abstractions are, in my opinion, an order of magnitude more difficult to assimilate than, say, higher-order functions. There is also at least an order of magnitude difference in the number of exercises available, but it is in the wrong direction.
Granted, Haskell Programming from First Principles does make you write a lot of instances of these abstractions in classic cases. Unfortunately it missed the other parts, and made me feel a bit like having proved a bunch of lemmas with very little idea of where those lemmas might be useful.
I think this is relevant for the Haskell community in general. If we can find pointers to good exercises, or examples that can be turned into exercises, I can create a public github repo and start collecting the material into one place.