View Source Reather (reather_lite v0.1.2)

Reather is the combined form of Reader and Either monad. A Reather wrapps an environment and the child functions can use the environment to access the values.

The evaluation of Reather is lazy, so it's never computed until explicitly call Reather.run/2.

Link to this section Summary

Functions

Get the current environment.

Inspect the reather.

Map the function to the reather.

Create a new Reather from the function.

Create a Reather from the value.

Run the reather.

Create a Reather from the value. If the value is Reather, it will be returned as is.

Link to this section Functions

Get the current environment.

Inspect the reather.

Warning: It runs the reather. So, the provided reather should not have side effects.

Map the function to the reather.

map is lazy, so it's never computed until explicitly call Reather.run/2.

iex> r = reather do
...>       x <- {:ok, 1}
...>       x
...>     end
iex> r
...> |> Reather.map(fn x -> x + 1 end)
...> |> Reather.run()
{:ok, 2}

Create a new Reather from the function.

Create a Reather from the value.

Link to this function

run(reather, arg \\ %{})

View Source

Run the reather.

Create a Reather from the value. If the value is Reather, it will be returned as is.

example

Example

iex> %Reather{} = Reather.wrap(:ok)

iex> r = %Reather{}
iex> ^r = Reather.wrap(r)