Lathe: pure incremental error-polymorphic byte parser

Initially I just wanted to modify binary so that it no longer mushes chunks together on rollback (binary#208), but then I realized that a pure parser really only has one real error in it (“reached end”), so that error type can be an argument instead.

The result is a remarkably generic, yet still quite efficient, pure incremental parser. Currently only supports binary primitives, Unicode encodings and number parsing, but could be extended to support virtually anything in a composable manner.

(there’s also lathe-time for building RFC 3339 times)


The parser was created in tandem with a general-purpose JSON library that I believe is good enough to be called json. Feel free to test-drive both of these and gently prod Galois Inc. if you find the JSON library to your liking.

10 Likes

I love the name :grin: At a glance, the API is very readable and has everything I’d want too.

I’ve been putting off writing a UBJSON Haskell parser (for parsing slippi replays) partially because none of the binary parsers felt quite right.