Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Allow arguments for extractor #127

Open
Adam-Vandervorst opened this issue Jun 28, 2020 · 0 comments
Open

Allow arguments for extractor #127

Adam-Vandervorst opened this issue Jun 28, 2020 · 0 comments

Comments

@Adam-Vandervorst
Copy link

Description

At the moment, there is no way to directly pass arguments to extractors.
This limits the explosiveness and the workaround isn't neat.
If constant arguments could be passed, extractors would gain significant power.

Current

If you need to pass arguments, currently you need to do something like below.
This is because partial application or applications of givens is not allowed.

    given field as (String, Int) = "y"->2
    Foo(1, 2) match {
      case f @ HasField() => println(s"y is 2, x is ${f.x}")
      ...
    }

and

    term match {
      case l: Lam if BuildCx(BUF_CRITERIUM).probable(l)  => BufRewrite(l, hist)
      case l: Lam if BuildCx(PROP_CRITERIUM).probable(l)  => Propagate(l, parents)
      case l: Lam if eqv(l, Id)  => BlackHole
      case l: Lam if eqv(l, S)  => OptimizedS
      ...
    }

Proposed

If arguments are allowed, the above code could be written as

    Foo(1, 2) match {
      case f @ HasField("y"->2) => println(s"y is 2, x is ${f.x}")
      ...
    }

and

    term match {
      case l @ CxPropably(BUF_CRITERIUM)  => BufRewrite(l, hist)
      case l @ CxProbably(PROP_CRITERIUM)  => Propagate(l, parents)
      ...
      case l @ EqvTo(Id)  => BlackHole
      case l @ EqvTo(S)  => OptimizedS
      ...
    }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant