gibbon-0.3: A compiler for operating on serialized data
Safe HaskellSafe-Inferred
LanguageHaskell2010

Gibbon.Passes.FindWitnesses

Description

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

Documentation

findWitnesses :: Prog2 -> PassM Prog2 Source #

This pass must find witnesses if they exist in the lexical environment, and it must *reorder* let bindings to bring start/end witnesses into scope.

Phase Ordering: This must run after flatten.