stephan-tolksdorf / fparsec

A parser combinator library for F#
523 stars 45 forks source link

Will the slowness warning of computation expressions be moot after f#5? #60

Open travis-leith opened 4 years ago

travis-leith commented 4 years ago

The documents warn us that using computation expressions will be slower than we might expect.

The upcoming release of F#5 is adding support for applicatives in computation expressions. Will this slowness still be an issue if we use the new applicative syntax, provided FParsec provides support for it?

baronfel commented 3 years ago

Adding support for applicatives can definitely address some of the underlying concerns, as instead of nested calls to Bind, independent parsers can be run individually and collected up into a single value for passing to the next Bind call via MergeSources and/or BindN/BindReturn overloads.

There will likely be some additional overhead still compared to manual parser writing, but I would naïevely expect the performance gap to shrink massively.

And perhaps with state machine additions coming sometime in the future the parse CE could actually compile down to low/zero-overhead state machines.