[Haskell-cafe] tokenize parser combinators and free applicatives
Nickolay Kudasov
nickolay.kudasov at gmail.com
Tue Oct 18 12:29:46 UTC 2016
Hi Ruben,
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.
Kind regards,
Nick
On Tue, 18 Oct 2016 at 15:12 Ruben Astudillo <ruben.astud at gmail.com> wrote:
> Hi all
>
> on [1] 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.
>
> [1]: 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:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20161018/e7018657/attachment.html>
More information about the Haskell-Cafe
mailing list