"unexpected end of input, expecting end of input"
- Dominant language
- Haskell
- Stars
- 892
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
Weird error message coming from parsec...
```haskell
#!/usr/bin/env stack
-- stack runghc --package parsec
import Data.Map (fromList)
import Text.Parsec
sepBy1Try p sep = do
x <- p
xs <- many (try $ sep *> p)
return (x : xs)
key =
try (string "byr")
<|> try (string "cid")
<|> try (string "eyr")
<|> try (string "ecl")
<|> try (string "hgt")
<|> try (string "hcl")
<|> try (string "iyr")
<|> try (string "pid")
passportKV = try $ do
k <- key
char ':'
v <- many1 (try alphaNum <|> try (char '#'))
return (k, v)
passportLine = sepBy1Try passportKV space
passport = do
lines <- sepBy1Try passportLine endOfLine
return $ fromList [kv | line <- lines, kv <- line]
passports = sepBy1 passport (endOfLine *> ((try endOfLine *> pure ()) <|> eof))
main = do
raw <- readFile "input.txt"
print $ parse passports "(poop)" raw
```
and here's the input file:
[input.txt](https://github.com/haskell/parsec/files/5733606/input.txt)
Here's what I get:
```
❯ ./day4.hs
Left "(poop)" (line 1134, column 1):
unexpected end of input
expecting new-line, end of input, "byr", "cid", "eyr", "ecl", "hgt", "hcl", "iyr" or "pid"
```
which seems... highly counter-intuitive!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.