
On Sat, 11 Apr 2009 09:37:53 -0700
Michael Mossey
One other question. Later in the chapter they define peekByte as follows:
-- file: ch10/Parse.hs peekByte :: Parse (Maybe Word8) peekByte = (fmap fst . L.uncons . string) <$> getState
Here they are accessing the 'string' field of the state. So whomever writes this function needs to have the accessor functions. At this point I'm wondering how much state is really getting hidden. Or maybe peekByte would only be written inside the original library.
Even before worrying about the accessor functions, a parsing library would in the first place not even export getState, putState, or the ParseState type. It would instead provide functions like parseByte and peekByte as primitives from which all complex parsers will be built.