You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While trying to combine Get parsers using asum, I found out that instance Alternative Get is not lawful: x <|> empty is not the same as x with respect to failure. x <|> empty errors with "Data.Binary.Get(Alternative).empty", overriding the error message from x.
For me, an unfortunate consequence is that the implementation of asum leaks through: asum [x, y] = x <|> y <|> empty provides less helpful parse errors than x <|> y.
Hello,
While trying to combine
Get
parsers usingasum
, I found out thatinstance Alternative Get
is not lawful:x <|> empty
is not the same asx
with respect to failure.x <|> empty
errors with"Data.Binary.Get(Alternative).empty"
, overriding the error message fromx
.For me, an unfortunate consequence is that the implementation of
asum
leaks through:asum [x, y] = x <|> y <|> empty
provides less helpful parse errors thanx <|> y
.I have attached a minimal working example, also hosted on this Gist: https://gist.github.com/sugarbleat/4f30751feedf8d3e06911deae7ef4a5a, which can be run with
cabal run Main.hs
. For reference, a similar test with Parsec shows no violation of identity.Thanks for the great work on the library, by the way!
The text was updated successfully, but these errors were encountered: