Come to think of it, a parsec parser already wraps over Either, so if all you want to do is check if a result is valid, you can abuse the Either semantics so that your type is:
Parser () -- the parser which returns nothing on success or an error on failure. On Tue, Feb 19, 2013 at 3:20 PM, Alexander Solla <alex.so...@gmail.com>wrote: > 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 > > Parser (IO ()) > > 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. > > > > On Tue, Feb 19, 2013 at 3:02 PM, Sean Cormican <seancormic...@gmail.com>wrote: > >> 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. >> >> 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. >> >> http://www.haskell.org/haskellwiki/Parsing_a_simple_imperative_language >> >> 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 ? >> >> Thanks for any help, >> Seán >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> >
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe