This is nowhere near complete and has lots of issues, so don't use it until it's done. I'll add docs then. ...And I've replaced it with my rewrite in Haskell so I'm not working on this anymore, but I'm leaving it here (bugs and all).