+ +
then
in Ruby feels like a little sister to the as->
macro from clojure.
Most of the API code (and several other parts) in Tramline heavily make use of then
There's a couple of interesting things of note here.
+One, I think numbered params have a lot of scope in removing some of the block cruft and overnaming of things across then
blocks. Especially if the next in chain is visually obvious.
@client.workflows(repo)
+ .then { fetch_workflows(*1) }
+ .then { pick_active(*1) }
+ .then { transform_keys(*1) }
+
+The above feels more natural and less noisy than naming each intermediate step with similar sounding variable names.
+The second one is a controversial (perhaps even wrong) point. It seems to me that since then
is just a function, the general debuggability of something going wrong in the pipeline is easier to find out in the chain.
My (now fading) experience with threading macro debuggability has been less efficient; I end up adding taps and spies to figure out what part of the chain broke.
+I prefer an experience like:
+-
+
- write a pipeline +
- pipeline breaks in expression number 2 +
- errors output nudges you clearly in the direction of just tweaking expression number 2 +
- make the fix and the pipeline starts working again +