Commit Graph

4 Commits

Author SHA1 Message Date
Elf M. Sternberg 356d4561b2 Basic arithmetic works! 2015-08-29 21:45:36 -07:00
Elf M. Sternberg e0b6b44178 Hey, it runs the test. It doesn't return the right value, but... 2015-08-25 22:01:21 -07:00
Elf M. Sternberg db2e93b2f3 [refactor] Is this the functor/applicative/monadic life?
This is a big change.  For chapter 5, I ripped out all line/column
tracking and most error handling from the parser; it's now a plain
ol' Lisp parser, and if it's not close to CL 22.1.1, it's a hell of
a lot closer than it used to be.

In doing so, I reduced the size of the parser by about 40 lines.

TrackingReader takes every function in a Reader and puts that
debugging information *back*.  It turns out that all that information
was prelude and postlude to the act of parsing; by wrapping each
function in a decorator I was able to restore all that information,
and I only had to get it right exactly *once*.

In functional programming terms, this lifts:

	IO -> (atom | list)

to:

	IO with tracking -> Node (atom | list) with tracking

It's a totally free win without having to do much extra work.

Now, this check-in isn't perfect.  The tracking reader is still
tossing on some things, and because I don't have a robust type
system (it is Coffeescript, after all), I'm having to do the
decorating and wrapping by hand.  But I'm definitely on my way
to understanding the issues, and having a grasp on functors and
monoids.
2015-08-20 08:50:52 -07:00
Elf M. Sternberg 981baec645 Start of chapter 5 interpreters. New readers, too. 2015-08-18 07:09:47 -07:00