[Forgot to document bail! Bryan O'Sullivan **20071216055517] { hunk ./en/ch10-binary.xml 272 - a similar purpose as our earlier + a similar purpose to our earlier hunk ./en/ch10-binary.xml 296 - of Parse values in a hidden argument. Our - parseByte function doesn't take the parse - state as an argument. Instead, it has to call + of Parse values in a hidden argument. + + + Obtaining and modifying the parse state + + Our parseByte function doesn't take the + parse state as an argument. Instead, it has to call hunk ./en/ch10-binary.xml 337 + + + + + Reporting parse errors + + We carefully defined our Parse type to + accommodate the possibility of failure. The + (==>) combinator checks for a parse + failure and stops parsing if it runs into a failure. But we + haven't yet introduced the bail function, + which we use to report a parse error. + + &Parse.hs:bail; + + After we call bail, + (==>) will successfully pattern match + on the Left constructor that it wraps the error + message with, and it will not invoke the next parser in the + chain. This will cause the error message to percolate back + through the chain of prior callers. + }