Arrows (arrows v0.1.0)

A handful of (mostly) arrow macros with superpowers.

Summary

Functions

Like ||, except only defaults if the left is nil (i.e. false is valid)

Like ||, except with the logic applied by ~>

A more flexible drop-in replacement for the standard elixir pipe operator.

Like OK.~>

Functions

Link to this macro

l <|> r

(macro)

Like ||, except only defaults if the left is nil (i.e. false is valid)

Link to this macro

l <~> r

(macro)

Like ||, except with the logic applied by ~>

Link to this macro

l |> r

(macro)

A more flexible drop-in replacement for the standard elixir pipe operator.

Special features are unlocked when using the ... (ellipsis) on the right hand side:

  • The right hand side need not be a function, it can be any expression containing the ellipsis.
  • The ellipsis will be replaced with the result of evaluating the hand side expression.
  • You may use the ellipsis multiple times and the left hand side will be calculated exactly once.

You can do crazy stuff with the ellipsis, but remember that people have to read it!

Link to this macro

l ~> r

(macro)

Like OK.~>