A newbie question about Arrows.

Shawn P. Garbett listman@garbett.org
Thu, 9 Jan 2003 10:30:45 -0600


On Monday 06 January 2003 04:02 am, Nicolas Oury wrote:
> I think for example to event-driven arrows : we could make a pair of
> inputs without mixing the "event happened" information.

Here's one that's been baffling me: What about the case where you have tw=
o=20
arrows you want to combine. Suppose that each of these arrows are a strea=
m=20
processor, which process the type Either.

SP (Either a b) (Either a b)

Now combing these with the sequencing operator is straightforward. The ou=
tput=20
of the first SP becomes the input of the second.

(>>>) :: SP i o -> SP i o -> SP i o

Or in a routing diagram

In >- SP1 --> SP2 --> Out

But what if you wanted to mix up the routing of Left and Right from the E=
ither=20
above?

In(Left) -> SP1(Left)
In(Right) -> SP2(Right)
SP1(Right) -> SP2(Left)
SP2(Left) -> SP1(Right)
SP1(Left) -> Out(Left)
SP2(Right) -> Out(Right)

One could easily define an operator to do this, but then what if one want=
ed to=20
combine three arrows with arbitrary routing of the signal? The problem=20
becomes combinatorial quickly. Yet this is exactly what happens in circui=
t=20
design and signal routing, or complex object oriented code. I imagine thi=
s=20
like a multi-layer circuit board, each SP maintains it's own state and=20
operates on multiple streams. The routing of these streams is arbitrary a=
nd=20
complex.

Maybe I'm just missing something trival and there's a simple way to do th=
is=20
already with arrows.

Shawn