Witchcraft.Functor.Proto protocol (Witchcraft v1.0.4) View Source

Protocol for the Elixir.Witchcraft.Functor type class

For this type class's API, please refer to Elixir.Witchcraft.Functor

Link to this section Summary

Functions

map a function into one layer of a data wrapper. There is an autocurrying variant: lift/2.

Link to this section Types

Link to this section Functions

Specs

map a function into one layer of a data wrapper. There is an autocurrying variant: lift/2.

Examples

iex> map([1, 2, 3], fn x -> x + 1 end)
[2, 3, 4]

iex> %{a: 1, b: 2} ~> fn x -> x * 10 end
%{a: 10, b: 20}

iex> map(%{a: 2, b: [1, 2, 3]}, fn
...>   int when is_integer(int) -> int * 100
...>   value -> inspect(value)
...> end)
%{a: 200, b: "[1, 2, 3]"}