[Haskell-beginners] Re: a better way to do this

Heinrich Apfelmus apfelmus at quantentunnel.de
Thu Apr 9 21:01:20 EDT 2009

Michael P Mossey wrote:
> Michael P Mossey wrote:
>> This is an early attempt to create some kind of parser, for text that
>> is xml-like but not actually xml. This is probably a disaster by
>> Haskell standards... If someone could point me in the direction of a
>> better way of doing things, that would be great. I don't want to use
>> the existing parser library, not at first, because I want to learn
>> more from first principles (for now).
> To follow up my own post, I'm working through chapter 10 of "Real World
> Haskell" right now, and then I'll look at chapter 14 (Monads). I think
> this is a better way of creating parsers. Maybe I'll look at Parsec
> eventually too, although I want to do a lot of stuff myself for the
> learning exprience.

I don't think that doing it "the hard way by hand" is very enlightening,
especially since you are using regular expressions anyway. (By the way,
the latter are a niche in Haskell; any serious and also most non-serious
parsing tasks are best done with parser combinators. The popularity of
regular expressions in languages like Python or Perl is mainly due to
the lack of more general parsing abstractions in these languages.)

A much more rewarding introduction to parsing and parser combinators is
probably to understand and experiment with their implementations, for
instance by starting with

    Graham Hutton, Erik Meijer.
    Monadic Parser Combinators.



More information about the Beginners mailing list