Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optionally do not evaluate under binders (except lets) #1055

Merged
merged 4 commits into from
Sep 18, 2023

Commits on Sep 14, 2023

  1. refactor! make eval-under-binders an option with no alternatives

    This is a stepping-stone to making an option to not evaluate under
    binders for EvalFull.
    
    BREAKING CHANGE: This adds a new field to `EvalFullReq`, which is
    exposed in the APIs. Since it is an extra optional argument in the
    OpenAPI, old clients of the OpenAPI will still continue to work (this
    is not true of the richly-typed API).
    
    Signed-off-by: Ben Price <[email protected]>
    brprice committed Sep 14, 2023
    Configuration menu
    Copy the full SHA
    0f7deba View commit details
    Browse the repository at this point in the history
  2. feat: optionally do not evaluate under binders

    This change means our EvalFull is "closed evaluation", rather than
    "open evaluation". The main reason to do this is so that evaluations of
    programs-in-construction (especially recursive ones) do not pointlessly
    blow up in size: if `even` and `odd` are defined recursively, then
    evaluating `even`  would evaluate under the lambda and inside case
    branches, expanding `odd` and recursing; when it eventually times out
    one would have a big tree with many unrolled copies of `even` and `odd`,
    which is not very illuminating.
    
    Note that the reduction of "pushing a let down", e.g.
    `let x = t in f s  ~> (let x = t in f) (let x = t in s)` happens at the
    `let` node, and thus is not "under" the `let x` binder.
    
    Note that we consider a "stack" of lets `let x=s in let y=t in r` to be
    one binder, so that we can (with `groupedLets = False`) reduce this by
    pushing the `let y` into the `r` (i.e. we don't count this as "under"
    the `let x` binder). We will not evaluate inside the `r`.
    
    Note that we do not evaluate in the RHS of pattern match branches which
    bind variables, for the same reason as we do not evaluate under lambdas;
    for consistency we also do not evaluate in the RHS of branches which do
    not bind variables.
    
    Signed-off-by: Ben Price <[email protected]>
    brprice committed Sep 14, 2023
    Configuration menu
    Copy the full SHA
    e42b7e9 View commit details
    Browse the repository at this point in the history
  3. feat: OpenAPI evalFull defaults to StopAtBinders

    Signed-off-by: Ben Price <[email protected]>
    brprice committed Sep 14, 2023
    Configuration menu
    Copy the full SHA
    5e4ed98 View commit details
    Browse the repository at this point in the history
  4. test: closed eval behaves fine with holes

    Signed-off-by: Ben Price <[email protected]>
    brprice committed Sep 14, 2023
    Configuration menu
    Copy the full SHA
    8a6a846 View commit details
    Browse the repository at this point in the history