haskell / haskell/parsec

parser never returns

Open
#60 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
Haskell
Stars
892
Forks
99
PR merge metrics
No merged PRs in 30d

Description

This is a primitve csv parser which skips intermediate blank lines:

``` haskell
parser :: Stream s m Char => ParsecT s u m [[String]]
parser = line `sepEndBy` (some endOfLine) <* eof
where line = many (noneOf ",\n\r") `sepBy` char ','
```

and looks like it works:

``` haskell
\> parse parser "" "1,2,3\n\n\n4,5,6"
Right [["1","2","3"],["4","5","6"]]
```

but if i change `some` to `many`:

``` haskell
parser :: Stream s m Char => ParsecT s u m [[String]]
parser = line `sepEndBy` (many endOfLine) <* eof
where line = many (noneOf ",\n\r") `sepBy` char ','
```

it will never return:

``` haskell
\> parse parser "" "1,2,3\n\n\n4,5,6"
^CInterrupted.
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the hang with the two parser definitions and the input shown in the issue. Start by tracing how sepEndBy combines line with many endOfLine, then compare that behavior with some endOfLine. Done means the parser terminates and its handling of intermediate blank lines is covered by a verified result.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.