On Jan 31, 2013, at 10:47 , Jan Stolarek <jan.stola...@p.lodz.pl> wrote:
> Thanks for replies guys. I indeed didn't notice that there are monads and > applicatives used in > this parser. My thought that monadic parsers are more verbose came from > Hutton's paper where the > code is definitely less readable than in example I provided. > > There is one more thing that bothers me. It is easy to write a parser that > returns Nothing when > parsing fails. But I can't figure out a way to add meaningful error messages > so that the user > knows where did the parsing fail. I experimented with using Either so that I > can use Left to pass > error messages but this turned out to be inflexible and clutered the code. I > will be greatful for > any ideas. Use the uu-parsinglib library, which provides error messages, repairs your errors and using its idioms definition you can even write: inParens c = iI '(' c ')' Ii I think you cannot get it shorter and with more functionality. Doaitse > Janek > > _______________________________________________ > 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