[Haskell-cafe] Gluing pipes

Matt Hellige matt at immute.net
Thu Dec 4 15:59:52 EST 2008

On Thu, Dec 4, 2008 at 12:52 PM, Dan Piponi <dpiponi at gmail.com> wrote:
> On Thu, Dec 4, 2008 at 10:21 AM, Matt Hellige <matt at immute.net> wrote:
>>  \ f x y z -> f x z y == id ~> flip
>> It's not clear to me whether your operad class can express this (or
>> whether operads in general can express this)
> There exists an operad that can (at the cost of even more notation),
> but you're right that the specific operad that I implemented can't.

Makes sense. It turns out that with one more definition, we can
express this fairly easily in my approach:
  infixr 2 ~*>
  (~*>) = (.)
Now we can use functions that inspect multiple arguments, without
moving our "position" in the argument list:
  f w x y z = concat $ map show [w,x,y,z]
  ex1 = (f $. id ~> flip ~*> id ~> id ~> length ~> id) 1 2 3 [4,5,6,7]
  roll f x y z = f y z x
  ex2 = (f $. id ~> roll ~*> id ~> id ~> length ~> id) 1 [4,5,6,7] 3 2
However, I have grave doubts about the usefulness of this, and I think
it more than sacrifices whatever we gained in clarity. I maintain that
($.) and (~>) are clear and useful, but this seems to be one step too

> Actually, if you look at the papers, mathematicians do have a
> perfectly good notation for this, and it'd be cool if there were a
> programming language that supported it well: drawing diagrams!

Hear, hear!

> Johannes Waldmann said:
>> Well, there is Combinatory Logic.
> But it's not known for its ease of use :-)

And we'd also have to change the definitions of all of our functions.
Ideally, we'd like the same definitions to work either way.

Anyway, thanks for all your thoughts...


More information about the Haskell-Cafe mailing list