<div dir="ltr">If all you want to do is check that the code is valid (i.e., you aren't going to interpret the code), you can just return a Bool. If you want to interpret it, but don't want to have a Stmt type, you can return IO () actions. In that case, the parser's type will be<div>
<br></div><div>Parser (IO ())<br><div><br></div><div style>I think an algebraic AST (or even a functorial/monadic one) will help separate concerns, and will eventually help when it comes time to optimize your compiler. It really isn't as much boilerplate as it looks like (in fact, there's hardly any boilerplate if you target free monads and interpret those in IO), and you get the type safety for which Haskell is well-known.</div>
</div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 19, 2013 at 3:02 PM, Sean Cormican <span dir="ltr"><<a href="mailto:seancormican1@gmail.com" target="_blank">seancormican1@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I have been trying to create a parser for a functional programming language, but there is no need to create an AST but merely check that the code is valid according to the grammar.<div>
<br></div><div>In the following tutorial I have been trying to take some pointers from, data declarations are used to create an AST for the language, There is, as I understand a way to parse the language without an AST. </div>
<div><br></div><div><a href="http://www.haskell.org/haskellwiki/Parsing_a_simple_imperative_language" target="_blank">http://www.haskell.org/haskellwiki/Parsing_a_simple_imperative_language</a><br></div><div><br></div><div>
My question is what should the type signatures for example parseFile function instead of "Stmt" accept as input if the parser is to accept Strings and numerical expressions alike ? </div><div><br></div><div>
Thanks for any help,</div><div>Seán </div></div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div>