Tag Archives: currying

Un-currying with Actors

This is an illustration of a sequential computation with actors and graphic lambda calculus, based on the ideas from  Actors for the Ackermann machine .  It describes the inverse of the currying process described in  Currying by using zippers and an allusion to the cartesian theater.

Without further ado, let’s watch the play.

The preparation consists in introducing the cast and the initial actors diagram.

actor_curry_prep

The play starts. The actor c introduces a to b and dies, or maybe goes playing elsewhere.

actor_curry_1

We see the states of the actors a and b, the other main character d is waiting for his line, while the figuration b1, ..., bN wait in the back of the stage, in artful positions.

The rest of the process consists in unzipping a graphic lambda calculus zipper. Zippers are very useful, because the unzipping process is sequential, i.e. it can happen in only one way. Therefore, by using zippers we can force a naturally distributed parallel computation to happen in a sequential way!

actor_curry_N

At the end of the computation, the two actors a and b, which represent the two parts of the zipper, cancel one another. Eventually the graph D is now connected with the output to the address :out and with the inputs to the (addresses of the) figuration actors b1, ..., bN.

The graph D corresponds to the graph A from  the post   Currying by using zippers and an allusion to the cartesian theater  and the computation just described is a reversed computation of the one described in the mentioned previous post.

__________________________

As a side remark, graphic lambda calculus suggests that currying and un-currying should be eliminated at the preparation stage of a distributed computation. However, I took this example of computation with actors and GLC as a simple illustration and also for stressing that zippers can impose, if needed, an order of reduction moves in GLC.

__________________________

Currying by using zippers and an allusion to the Cartesian Theater

Here is a recipe for understanding currying with the help of zippers.  (Done in graphic lambda calculus.)

We have a graph A \in GRAPH which has one output and several inputs. We want to curry it. For this we have to artificially give names to the inputs, i.e. to number them (notice that such a thing is not needed in graphic lambda).

curry_1

The next step is to use a n-zipper in order to clip the inputs, by using n graphic beta moves, until we get this:

curry_2

This graph is, in fact, the following one (we replace the n-zipper, which is just a notation, or a macro, with its expression).

curry_3

The graph inside the green dotted rectangle is the currying of A, let’s call him Curry(A).  This graph has only one output and no inputs.  (The procedure of currying can be made itself into a graph which is applied to  the output of A, but we stop at this level for this post.) The graph inside the red dotted rectangle is almost a list. We shall transform it into a list by using again a zipper and one graphic beta move.

curry_4

Now we’re done!

As you see, the currying creates the list, or the list creates the currying, or both form a pair, like the homunculus Curry(A) and the scenic space List(1,2, ... , n), an allusion to my post on the Cartesian Theater.