ExOptional
provides a (minimal) set of functions to work with "Optional" types.
In Elixir, Optional types are really just two-element tuples. Success Optionals look like
{ :ok, value }
while failed Optionals have some other value for the first element. (ExOptional
uses :no
by default, but largely doesn't care.)
Currently, failed Optionals will only have a value of nil
. In the future, ExOptional
may support failed values as well.
If available in Hex, the package can be installed as:
- Add
ex_optional
to your list of dependencies inmix.exs
:
```elixir
def deps do
[{:ex_optional, "~> 0.1.0"}]
end
```
- Ensure
ex_optional
is started before your application:
```elixir
def application do
[applications: [:ex_optional]]
end
```