4 ms·
> ...as the way they're implemented in, say, Haskell has a lot of function call overhead that's hard to optimize. GHC inlines aggressively (when you use -O) so
by nybble41 8y ago
> ...as the way they're implemented in, say, Haskell has a lot of function call overhead that's hard to optimize.
GHC inlines aggressively (when you use -O) so there shouldn't be much function call overhead. As others have commented, the bigger issue is that monadic parsers are generally unable to perform static analysis of the full parse tree and thus identify the aspects which parallel branches have in common, which implies more backtracking and redundant parsing. Some of this can be improved heuristically with rewrite rules, or by explicitly using applicative combinators (which can be statically analyzed) instead of monadic ones.