Change equational constraints on IsString (Parser a) to a ~ ()#229
Change equational constraints on IsString (Parser a) to a ~ ()#229sol wants to merge 1 commit intohaskell:masterfrom
IsString (Parser a) to a ~ ()#229Conversation
|
I know this is kinda old now, but I'd recommend against this. While it's very rare to see use of the form parsePhrase :: Parser Text
parsePhrase = do
txt1 <- "Not" <|> "Already"
skipSpace
txt2 <- "enough" <|> "too many"
skipSpace
txt3 <- "fish" <|> "batteries"
void "."
return (txt1 <> " " <> txt2 <> " " <> txt3 <> ".")...unless this counts as a contrived example. I suppose a lot of the time, you'd be more likely to use If it's more efficient to return |
Have you written code like this yourself, or where have you seen this?
Yes, exactly. |
I think I just got this wrong when I originally implemented this (888b7d7, 0265427).
When you parse a constant string it is not really useful to inspect the parse result. For that reason I think it is justified to change the type from
Parser TexttoParser ().This doesn't make a difference for applicative-style code, but it helps with monadic code, making it
-Wallsane, e.g. you can now sayinstead of
Technically this is a breaking change, but I have a hard time to imagine non-contrived code that would break from this.