purescript-contrib / purescript-parsing

A parser combinator library based on Parsec
BSD 2-Clause "Simplified" License
149 stars 50 forks source link

New String function: parseErrorHuman #209

Closed jamesdbrock closed 1 year ago

jamesdbrock commented 1 year ago

New String function: parseErrorHuman

Returns three Strings which, when printed line-by-line, will show a nice human-readable parsing error message.

    let input = "12345six789"
    case runParser input (replicateA 9 String.Basic.digit) of
      Left err -> log $ String.joinWith "\n" $ parseErrorHuman input 20 err
Expected digit at position index:5 (line:1, column:6)
     ▼
12345six789

Checklist: