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 wrote:
>
>
> > On Apr 27, 2021, at 3:32 PM, Sebastian Graf wrote:
> >
> > Hi Richard
> 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 tha
Hi Richard,
perhaps something like this would work:
```Haskell
import Text.ParserCombinators.ReadP(readP_to_S, gather)
import qualified Text.Read.Lex as L
example :: ReadS (Int,String)
example input =
do ((xs,L.String t), rest) <- readP_to_S (gather L.lex) input
pure ((length xs, t), rest
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 yo