[Haskell-cafe] Parsing workflow
S D Swierstra
doaitse at uu.nl
Fri Jan 20 16:32:00 CET 2012
On Oct 31, 2010, at 17:15 , Nils Schweinsberg wrote:
> Am 31.10.2010 16:53, schrieb Vo Minh Thu:
>> I can't really tell from your description, but maybe this is because
>> of the way Parsec works when it deals with alternatives. When you
>> combine several parsers with e.g. '<|>' or 'choice', an alternative
>> that can consume some input but fails will make the whole combined
>> parser fail too. So you have to either factorize you parsers or use
>> the 'try'. See the documentation for 'try' at
> This is exactly what gives me headaches. It's hard to tell where you need try/lookAhead and where you don't need them. And I don't really feel comfortable wrapping everything into try blocks...
This is precisely why you should use a more general parser library like uu-parsing and try to avoid the more low-level techniques used in Parsec; uu-parsinglib avoids all the confusion arising from the use of try constructs. It furthermore gives you an online result, error correction and nice error messages. Its Utils module contains a lot of useful "standards" elements you might want to recognise.
Thus far i have only happy users, and if you are having any problems please let me know.
PS: for all parsing libraries it holds that parsing times are negligeable when compared to the time spent on what you want to do with the parsed result.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe