On Fri, Nov 16, 2012 at 5:13 PM, Christopher Howard <span dir="ltr"><<a href="mailto:christopher.howard@frigidcode.com" target="_blank">christopher.howard@frigidcode.com</a>></span> wrote:<div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thank you for your help. Can you elaborate a little more on your<br>
explanation? So, would "a" be some data type representing the atoms of<br>
the grammar? Or some kind of recursive data type that could represent<br>
any kind of valid structure? Or...?<br></blockquote><div><br></div><div>The type parameter "a" is the output of that particular parser. So, a parser for an integer might have type String -> Integer, while a parser for some complicated data type Foo would have type String -> Foo.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'll wait until I'm clear on that point before asking about how I would<br>
combine parsers. (Presumably, two combined parsers would both have to<br>
have the same "a" type.)<br></blockquote><div><br></div><div>Since the parsers in this scheme are just functions, there are endless ways they could be combined, and the input and output types may or may not match.</div>
<div><br></div><div>Some combinators you will probably want:</div><div><br></div><div>andThen :: Parser a -> (a -> Parser b) -> Parser b<br></div><div>orElse :: Parser a -> Parser a -> Parser a</div><div><br>
</div><div>And you might also want:</div><div><br></div><div>succeedWith :: a -> Parser a</div><div><br></div><div>-Karl</div></div></div>