Provides OK-piping (similar to libraries like ok) and adds the ability to pipe into any argument position (similar to magritte) of the following function (or nested function). By inserting ... where you would like the value to be inserted, Arrows will override where it is placed.
I see that the main difference between this and Magritte is that it do not have my limitations. Actually I have intentionally added these limitations to avoid things like:
foo
|> bar(fn a ->
a
|> baz(2137, ...) # what value should be inserted there?
end)
Also, when you want to use ... twice within single pipe there is question whether there should be 2 separate parent pipes or single one. Aka whether this code:
:rand.uniform()
|> Kernel.==(..., ...)
Should always return true?
I probably should have describe reasoning better in Magritte documentation.
Thanks for making this package! The ~> looks like a nice alternative to with. Any gotchas or downsides to be aware of? Looks like it could always be used in place of the |> or are there still scenarios where you’d want to use |>?
Also, would you mind documenting the other functions in more detail in the hex doc?
with serves a very different purpose. <- is a match operator much like = with the difference that it returns the value of the expression if there is no match instead of raising. with is about running its do block only when all of its clauses match. This package is just about being able to pipe into other positional arguments.
Oops, sorry I misread what ~> was. There is another library like this that uses ~>. My bad.
Regarding ~> I tend to use it mostly for short pipes where with may feel verbose, but for longer ones I prefer to be more explicit. In part because of this gotcha:
# Note that the following would pass :error to `String.pad_leading` breaking our pipe:
# :error ~> Integer.to_string() |> String.pad_leading(2, "0")
:error
# Instead we want to do:
iex> :error ~> Integer.to_string() ~> String.pad_leading(2, "0")
:error