Skip to content

An Elixir library that provides `nwith` macro for named fallbacks of `with`-like clauses.

License

Notifications You must be signed in to change notification settings

yondermon/nwith

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nwith

This library provides nwith macro for named fallbacks of with-like clauses.

Installation

The package can be installed as:

  1. Add nwith to your list of dependencies in mix.exs:
def deps do
  [{:nwith, "~> 0.1.0"}]
end
  1. Run mix deps.get in 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.

About

An Elixir library that provides `nwith` macro for named fallbacks of `with`-like clauses.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages