3 ms·
A scenario that made the need for 'with' clear to me: You have a function that passes a subject through several functions using the pipe: subject |> fn1 |> fn
by kiliancs 10y ago
A scenario that made the need for 'with' clear to me:
You have a function that passes a subject through several functions using the pipe:
subject |> fn1 |> fn2 |> fn3
But now you want to return an error monad if everything went wrong. You could do the following:
with {:ok, v1} <- f1(subject),
{:ok, v2} <- f2(v1),
do: f3(v2)