View Source Witchcraft.Semigroupoid.Proto protocol (Witchcraft v1.0.6-doma)

Protocol for the Elixir.Witchcraft.Semigroupoid type class

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

Link to this section Summary

Functions

Express how to apply arguments to the very end of a semigroupoid, or "run the morphism". This should not be used to inject values part way though a composition chain.

Take two morphisms and return their composition "the math way". That is, (b -> c) -> (a -> b) -> (a -> c).

Link to this section Types

Link to this section Functions

Link to this function

apply(morphism, arguments)

View Source

Express how to apply arguments to the very end of a semigroupoid, or "run the morphism". This should not be used to inject values part way though a composition chain.

It is provided here to remain idiomatic with Elixir, and to make prop testing possible.

examples

Examples

iex> Witchcraft.Semigroupoid.apply(&inspect/1, [42])
"42"
Link to this function

compose(morphism_a, morphism_b)

View Source

Take two morphisms and return their composition "the math way". That is, (b -> c) -> (a -> b) -> (a -> c).

examples

Examples

iex> times_ten_plus_one = compose(fn x -> x + 1 end, fn y -> y * 10 end)
...> times_ten_plus_one.(5)
51