haskell / haskell/attoparsec

Parser is bad Alternative

Open
#122 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
Haskell
Stars
531
Forks
98
PR merge metrics
No merged PRs in 30d

Description

`Alternative` is expected to be a monoid.

But for `Parser` we have:

``` haskell
import Prelude
import Data.Attoparsec.Text
import Control.Applicative

λ> parseOnly (fail "oops") "" == parseOnly (fail "oops" <|> empty) ""
False

λ> parseOnly (fail "oops") ""
Left "Failed reading: oops"
λ> parseOnly (fail "oops" <|> empty) ""
Left "Failed reading: empty"
```

Implications:
1. Adding `empty` erases useful error message.
2. User can't substitute `p1 <|> p2 <|> p3` with `asum [p1, p2, p3]` (`asum` always appends `empty` at the end).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.