1. tap:
I think adding tap will be very useful. I often am doing something like
```
ast = quote do ... end
IO.puts(Macro.to_string(ast)
ast
```
when debugging macros.
Being able to change this to
```
quote do ... end
|> tap(&IO.puts(Macro.to_string(&1))
```
will be very welcome. :-)
2. then:
What José is referring to (when talking about `then` in relation to other languages where it is also used for e.g. promises) is the monadic 'bind' operation. You might also know it as `>>=` as well as `andThen`:
- `>>=` is the (non-descriptive) symbolic name that is used in Haskell, PureScript, and F# as well as many papers.
- `bind` is the name given to above operation. It is also a frequently-used name whenever an operator is not used. In fact, `bind` is used in the Elixir ecosystem right now. One example that comes to mind is `StreamData`. There are probably others.
- `andThen` sees usage in Scala, Elm and as already mentioned by José in many other contexts whether they deal with only promises, only parsers, only nondeterminism, etc... or monads in general.
Even if it is more verbose, I think the name `andThen` is more descriptive than plain `then`. Therefore I prefer `andThen`.
But rather I'd not add it at all:
This proposed function will only be specialized to the "identity monad".
The bind operation is the place where the unwrapping of the monadic value ought to happen. The identity monad is the one case where there is nothing to unwrap.
`then/2` only exists for improved syntax, not for improved semantics.
The fact that we are specializing it for this single syntactic purpose makes me consider that maybe we'd be better off choosing a different name that does not have this pre-existing meaning attached.
Even if you're unfamiliar with monads or algebraic datatypes in general, you'll be able to understand the problem of restricting a general operation to one specific case.
It's a bit like saying "Let's add a `Kernel.sum/1` that sums (only) lists of integers." It 'works' but what about lists of floats? sets of integers? lists of decimals? etc.
There is a lot of missed potential.
There is a high possibility that a decision like this cannot be extended or altered later on in a backwards-compatible way.
There is a high likelihood of people trying to use it in contexts where it cannot be used and being confused by it or introducing bugs.
So I'd seriously consider using a different naming scheme for `then`.
I'd prefer a simpler name with less of a pre-existing meaning.
Possibly just `fun/2`.
Happy holidays! :-)
~Marten/Qqwy