attoparsec icon indicating copy to clipboard operation
attoparsec copied to clipboard

Change equational constraints on `IsString (Parser a)` to `a ~ ()`

Open sol opened this issue 8 months ago • 0 comments

I think I just got this wrong when I originally implemented this (https://github.com/haskell/attoparsec/commit/888b7d70a9dbbf4d58d349ca444f18f6560c8d61, https://github.com/haskell/attoparsec/commit/0265427d09d64e3292cb77cfecca4679ef60ccc3).

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 Text to Parser ().

This doesn't make a difference for applicative-style code, but it helps with monadic code, making it -Wall sane, e.g. you can now say

parser = do
  ...
  "foo"
  ...

instead of

parser = do
  ...
  _ <- "foo"
  ...

Technically this is a breaking change, but I have a hard time to imagine non-contrived code that would break from this.

sol avatar Apr 20 '25 10:04 sol