Pipechain: an alternative library to threading (with a few extras)

I loved the idea behind the threading package but I didn't like how it implicitly added the threaded argument to the end (or beginning). It will still treat a non-parenthesized expression as a function, but otherwise you need to use the _ variable.

Another thing I included in this package is an alternative to require that I think has a little more fluent syntax for renaming imports and pulling in everything with a prefix.

3 Likes

Hi Dyllon,

It's been a while since I used threading; can you nail down for me how your version differs? Is it simply that the _ is mandatory?

Also, speaking as a guy with a 'utils' collection that grew way out of control (cf the handy collection) and now regrets it, may I suggest breaking the require-safe and define-proc macros out into separate libraries? pipeline/utils can require and then re-export all of those things so nothing will change from the perspective of your code or those who use it, but it would allow people to pull in some of the cool stuff you've written while keeping their application's code size as small as possible if they're going to use define-proc but not the threading part.

I'll think about it, though I'm more a fan of large util libraries.

Another difference from threading is that it uses a syntax parameter for _. This allows for renaming _ if you desire, but more importantly, it allows for arbitrary nesting of ~>. I've run into scenarios where trying to nest ~> results in weirdness with _.

Also forgot to mention that "(define var)" can be used within ~> to keep track of a value within the ~> pipeline for later reuse (the binding does not escape ~> though).

2 Likes

Oh, cool. That's a very nice distinguishing feature as compared to threading. You should definitely document that.

Speaking of, the library currently has default empty documentation: pipechain Everything necessary is in the README file, so it would probably be a good idea to remove the Scribble.