[Haskell-cafe] Alternative instance for non-backtracking parsers

Bardur Arantsson spam at scientician.net
Fri Aug 31 14:47:09 UTC 2018


On 31/08/2018 14.50, Bryan Richter wrote:
> On 08/30/2018 03:43 PM, Bardur Arantsson wrote:
> 
>> On 30/08/2018 20.21, Olaf Klinke wrote:
>>
>>>> Hello, Olaf. I have some distrust of elegant solutions (one of
>>>> them are C.P. libs).
>>>
>>> [*] To the parser experts on this list: How much time should
>>> a parser take that processes a 50MB, 130000-line text file,
>>> extracting 5 values (String, UTCTime, Int, Double) from each line?
>>
>> Not an expert, but for something as (relatively!) standard
>> as CSV, I'd probably go for a specialized solution like
>> 'cassava', which seems like it does quite well according to
>> https://github.com/haskell-perf/csv
> 
> Playing the devil's advocate here....
> 
> If parser combinators aren't great for "relatively standard" things
> such as CSV, then what *are* they good for?
> 

Off the top of my head:

a) They're often much more readable than many alternatives if you
*don't* actually care *too* much about performance. (Especially if you
have semantic actions, I find that they're *much* more readable.)

b) They're usually a lot better for "tricky" languages which e.g. might
not be context-free.

c) Embedding the "grammar" directly in Haskell means that there's no
weirdness around integrating generated code/types with the rest of the
program.

(Probably several other obvious things, I'm forgetting.)

Regards,



More information about the Haskell-Cafe mailing list