Match on the end of a pipe (Matchpipe?)

defmacro {:|>, _line, [pipe, match]} ~> expr do
  quote do
    unquote(pipe)
    |> case do unquote(match) -> unquote(expr) end
  end
end
defmacro _ ~> _, do: raise ArgumentError, "~>/2 must be presided by a pipe"

{1,2} |> {x,y} ~> {x+1, foo(y)} etc… :sweat_smile:

4 Likes