Realm v0.1.0 Realm.Semigroupoid protocol View Source

A semigroupoid describes some way of composing morphisms on between some collection of objects.

Type Class

An instance of Realm.Semigroupoid must define Realm.Semigroupoid.compose/2.

Semigroupoid  [compose/2]

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. It is provided here to remain idiomatic with Elixir, and to make prop testing possible.

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
apply(t(), [any()]) :: t() | any()

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

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

compose(left, right)

View Source
compose(t(), t()) :: t()

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

Examples

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