[Haskell-cafe] tokenize parser combinators and free applicatives
nickolay.kudasov at gmail.com
Tue Oct 18 12:29:46 UTC 2016
I imagine, free applicative would allow you to easily insert
whitespace/comment eaters afterwards. For instance, say you have Parser
applicative for parsing. Then Ap Parser would represent the same parser,
but with parsing combinators separated with Ap constructors. You would use
Ap Parser when defining your grammar. Then you could "intersperse"
whitespace eaters in between the combinators and "retract" the resulting Ap
Parser into just Parser. That would probably be a cleaner approach compared
to having every combinator wrapped in trimWhiteSpacesAndComments combinator.
On Tue, 18 Oct 2016 at 15:12 Ruben Astudillo <ruben.astud at gmail.com> wrote:
> Hi all
> on  it is said the following
> "Dealing with whitespace and comments is awkward in the parser; you
> need to wrap everything in a token combinator. (If you decide to do
> that, at least use a free applicative functor to ensure that you
> don’t forget to consume that whitespace)."
> Reading on `free` the def of Ap, frankly I don't see how can the free
> applicative be used for this. Anybody could drop a hint? I would
> appreciate it.
> : https://ro-che.info/articles/2015-01-02-lexical-analysis
> -- Ruben
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe