Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
With the new location calculus and inferLocations
, this pass should've been
redundant. But not quite.. We still need it to reorder location variables bound
in case expressions.
For example, after running the add1 program through the pipeline till RouteEnds
,
this is what the Node
case looks like:
(Node, [("x9", "l10"),("y11", "l12")], ...)
To "unpack" these fields, Cursorize
just binds x9
to l10
and y11
to l12
.
But, the cursor l12
is not bound (or known) until we call `(add1 x9)` and
get the end_of_read cursor it returns. This happens later in the program.
Thus, y11
refers to an unbound cursor l12
here.
FindWitnesses fixes this by moving the `let y11 = l12` binding to its proper place.
Another strategy would be to actually handle this properly in Cursorize.
Synopsis
- findWitnesses :: Prog2 -> PassM Prog2