
Hello Richard,
Just FYI `gather` doesn't work with `readS_to_P` (throws an error), so
you'll have to stick to ReadP parsers but, hopefully, that's OK.
-Iavor
On Tue, Apr 27, 2021 at 7:14 PM Richard Eisenberg
On Apr 27, 2021, at 3:32 PM, Sebastian Graf
wrote: Hi Richard,
Maybe I lack a bit of context, but I don't see why you wouldn't choose (3). Extending the lexer/parser will yield a declarative specification of what exactly constitutes a GHC_OPTIONS pragma (albeit in a language that isn't Haskell) and should be more efficient than `reads`, even if you fix it to scale linearly. Plus, it seems that's what we do for other pragmas such as RULE already.
(3) is tempting indeed. There are two problems:
A. The code that parses strings isn't actually declarative. See https://gitlab.haskell.org/ghc/ghc/-/blob/d2399a46a01a6e46c831c19e797e656a0b.... In particular note the comment: "This stuff is horrible. I hates it." Evidently written by Simon M in 2003 with the introduction of alex.
B. We need this code outside the lexer, to deal with e.g. :set in GHCi.
On Apr 27, 2021, at 4:28 PM, Iavor Diatchki
wrote: ... gather ...
Aha! That was the magic incantation I needed but did not have. Many thanks, Iavor.
The curious can see https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5509/diffs?commit_id=a56... for the final result.
Thanks! Richard _______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs