Witchcraft v1.0.0-beta Witchcraft.Apply.Proto protocol View Source

Protocol for the Elixir.Witchcraft.Apply type class

For this type class’s API, please refer to Elixir.Witchcraft.Apply

Link to this section Summary

Functions

Apply argumnets to a function, when both are wrapped in the same data structure

Link to this section Types

Link to this section Functions

Apply argumnets to a function, when both are wrapped in the same data structure

Examples

iex> ap([fn x -> x + 1 end, fn y -> y * 10 end], [1, 2, 3])
[2, 3, 4, 10, 20, 30]

iex> [100, 200]
...> |> Witchcraft.Functor.lift(fn(x, y, z) -> x * y / z end)
...> |> ap([5, 2])
...> |> ap([100, 50])
[5.0, 10.0, 2.0, 4.0, 10.0, 20.0, 4.0, 8.0]
# ↓                          ↓
# 100 * 5 / 100          200 * 5 / 50