# Parsers with Error Recovery

**URL:** <https://discourse.elm-lang.org/t/parsers-with-error-recovery/6262>\
**Category:** Learn\
**Created:** [September 8, 2020, 3:12pm UTC](https://discourse.elm-lang.org/t/parsers-with-error-recovery/6262 "2020-09-08T15:12:52Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![rupert](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/rupert/32/1775_2.png) [@rupert](https://discourse.elm-lang.org/u/rupert)\
**Post date:** [September 25, 2020, 8:50am UTC](https://discourse.elm-lang.org/t/parsers-with-error-recovery/6262/18 "2020-09-25T08:50:07Z")

</div>

I tried to keep the API idential to `Parser.Advanced`, so switching over to it should be relatively easy. All the functions should behave the same way as the corresponding functions in `Parser.Advanced`. The behaviour should only change when you apply one of the recovery tactics.

I cannot export `(|.)` and `(|=)` though, due to kernel code restrictions :-(. So you have to re-write those:

```elm
import Parser.Advanced as PA exposing ((|=), (|.))

parser = 
    PA.succeed identity
        |. PA.spaces
        |= PA.int
        |. PA.spaces

```

to

```elm
import Parser.Recoverable as PR

parser = 
    PR.succeed identity
        |> PR.ignore PR.spaces
        |> PR.keep PR.int
        |> PR.ignore PR.spaces

```

Another difference is that where functions like `Parser.Advanced.keyword` take a `Token` argument, I thought just passing in the `String` and `problem` without wrapping as a `Token` was neater:

```elm
PA.keyword (PA.Token "let" ExpectingLet)

PR.keyword "let" ExpectingLet

```

I’ll likely make a release soon - I’m trying to figure out how to make a recoverable version of `sequence` first. The fast-forward recovery at the moment fast forwards to a sentinal `Char`, then continues. But `sequence` uses `String`s as separators not `Char`s, so I need to implement a slightly different fast-forward mechanism, then it will be good to go. I’ll just push it out with the recovery tactics I implemented so far, it will be interesting to hear if they work for you, or if you find they need to be modified to cover situations you are encountering.

---

_[View the full topic](https://discourse.elm-lang.org/t/parsers-with-error-recovery/6262)._
