Re: [stack] function "adjoinment"?
Matt Hellige <[email protected]> Sun, 31 Jan 2010 20:40:53 -0600
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Jan 31, 2010 at 5:22 PM, John Nowak <[email protected]> wrote: > > > > We're familiar with the notion of function composition: > > (a -> b) -> (b -> c) -> (a -> c) > > However, is anyone familiar with a notion of function "adjoinment"? > Given a function F that takes a tuple A to a tuple B, and a function G > that takes a tuple C to a tuple D, the adjoinment of F and G would be > a function that takes the concatenation of A and B to the > concatenation of C and D. In other words: > > (a -> b) -> (c -> d) -> (a++b -> c++d) > where ++ is concatenation and a,b,c,d are tuples/stacks > This reminds me of the *** operator in Haskell's Arrow library, which, when specialized to the (->) arrow, has type (a->c) -> (b->c) -> (a,a') -> (b,b'). You can use this to do something similar, and with isomorphisms (a,(b,c)) <=> ((a,b),c), you can treat it like a more general concatenation version. The special syntactic sugar for arrows hides the tuple plumbing and makes this reasonably pleasant, but of course Haskell's type system doesn't actually allow us to abstract over tuples of arbitrary length. I wonder if it would be possible to type this operator in a system of extensible records like Daan Leijen's Morrow? That would be a neat trick. Finally, it also reminds me of operads. I've speculated a bit about a general syntax for operadic composition, but don't really have anything useful to say. Matt