Integrated Dynamics

Integrated Dynamics

63M Downloads

We need to do the opposite of currying

josephcsible opened this issue · 2 comments

commented

Currently, we perform currying, where if you call a function with less arguments than it needs, it gets partially applied. We need to do the opposite of that as well, where if you call a function with too many arguments, the remaining ones get passed to the function's output, transforming f(a, b) to (f(a))(b) for example.

Here's a concrete case that doesn't work as expected:

  1. Create variable cards with the number 3, the Increment operator, and the Identity operator.
  2. Go to Flip in the logic programmer, put in Identity, and get the resulting card (I'll call it "CI").
  3. Go to Apply 2 in the logic programmer, put in CI, 3, and Increment, and get the resulting card.
  4. Put that card in a display panel.

The expected result is the number 4, but instead you get an error: "The given config render pattern with 2 slots is not compatible with the number of input types 1 for :flip".

Here's what I expect to happen, written in combinatory logic style:

  • Flip Identity 3 Increment
    • Apply beta reduction to Flip (λxyz.xzy):
  • Identity Increment 3
    • Apply beta reduction to Identity (λx.x):
  • Increment 3
    • Evaluate the Increment operator:
  • 4

(Edit: In fact, you get the error much sooner by just attempting to materialize CI.)

commented

Ok, I understand the problem. This is indeed something I did not take into account while implementing currying. But AFAICS, it should be possible to implement this in the current system without any major changes nonetheless.

commented

In case anyone else is experiencing this issue, a workaround is to use "Apply" (or "Apply2" or "Apply3" in case of really complicated examples) in place of "Identity". This won't change the meaning of your expression, since they're equivalent up to eta-conversion.