Nwith
This library provides nwith macro for named fallbacks of with-like clauses.
Installation
The package can be installed as:
-
Add nwith to your list of dependencies in
mix.exs:
def deps do
[{:nwith, "~> 0.1.0"}]
end-
Run
mix deps.getin your console to fetch from Hex.
Usage
iex> import Nwith, only: [nwith: 2]
iex> nwith firstly: {:ok, value} = result <- {:ok, true},
...> secondly: true <- value,
...> finally: {:ok, true} <- result do
...> "The result is " <> inspect(result)
...> else
...> secondly: false ->
...> "Not gonna happen"
...>
...> secondly: nil ->
...> "Just nothing"
...>
...> finally: error ->
...> "Something went wrong: #{inspect(error)}"
...> end
"The result is {:ok, true}"License
Nwith source code is released under Apache 2 License.
Check the LICENSE file for more information.