Prelude function suggestions

Marcin 'Qrczak' Kowalczyk qrczak at
Wed Jul 28 13:35:28 EDT 2004

W liście z śro, 28-07-2004, godz. 18:59 +0200, Peter Simons napisał:

> IMHO, Parsec is too complicated for something that simply.

It is, but I don't have anything else.

> Stick to the example of implementing a 'lines' that uses
> \r\n instead of \n, if you will: I don't want any monads,
> I don't want error messages, I don't need any recursive
> descent parser.

let splitLines str = result
    Right result = parse (anyChar `manyTill` sep `manyTill` eof) "" str
    sep = (char '\n' >> return ())
      <|> (try (string "\r\n") >> return ())
      <|> eof

BTW, IMHO the 'string' function should use 'try' automatically.

   __("<         Marcin Kowalczyk
   \__/       qrczak at

More information about the Libraries mailing list