Re: simple Haskell help needed on #19746

2021-04-28 Thread Iavor Diatchki
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

Re: simple Haskell help needed on #19746

2021-04-27 Thread 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 tha

Re: simple Haskell help needed on #19746

2021-04-27 Thread Iavor Diatchki
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

Re: simple Haskell help needed on #19746

2021-04-27 Thread Sebastian Graf
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