Justin Garcia @purefunctor.me · Dec 28

In PureScript, bind and discard share a prefix in the form of binders and expressions e.g. value <- 123 pure value Determining if `value` is a binder or an expression requires unbounded lookahead for '<-', which is how I ended up writing this API for backtracking.

0 likes 2 replies

?

Replies

Justin Garcia · Dec 28

A potential optimization here is to short-circuit on: VAR '<-' which is one of the most common forms of a do statement, which should allow the parser to skip the branching altogether. I can imagine that in a trivial environment it won't amount to much but in an IDE context it could prove useful!

Justin Garcia · Dec 28

The `decide` function picks the longest branch without errors. If all branches have errors, it just takes the first one and lets the recovery mechanism kick in.