4 ms·
"I have no idea what the program presented is supposed to do, or what problem is being solved, despite knowing all the types being used." This is an absolutely
by sacundim 13y ago
"I have no idea what the program presented is supposed to do, or what problem is being solved, despite knowing all the types being used."
This is an absolutely fair observation. The code being shown is basically chowells79's recreation of a library that I wrote about a year ago:
http://hackage.haskell.org/package/free-operational http://hackage.haskell.org/package/free-operational
Basically, it really only makes sense once you've studied and grasped the key ideas behind a handful of other things: (a) functors, applicatives and monads; (b) the `operational` monad (another library, which mine recreates and expands on); (c) free monads (yet another library).
If you look at the link above, you'll note that I've chosen to follow the opposite approach—I provide links to other sources that provide the background context for what the library is doing. Elsewhere in the documentation I provide extended (but toy) examples of how to use it, of which I'd highlight the one in here:
http://hackage.haskell.org/package/free-operational-0.5.0.0/docs/Control-Alternative-Operational.html http://hackage.haskell.org/package/free-operational-0.5.0.0/...
That page's example demonstrates a toy implementation of parser combinators and three different ways of using it: (a) parsing strings, (b) enumerating the strings that a parser accepts, and (c) optimizing parsers by merging paths with common prefixes.
So basically, the library is a kind of interpreter construction toolkit. A very abstract one...