Realm v0.1.0 Realm.Semigroup protocol View Source

A semigroup is a structure describing data that can be appendenated with others of its type. That is to say that appending another list returns a list, appending one map to another returns a map, and appending two integers returns an integer, and so on. These can be chained together an arbitrary number of times. For example:

1 <> 2 <> 3 <> 5 <> 7 == 18
[1, 2, 3] <> [4, 5, 6] <> [7, 8, 9] == [1, 2, 3, 4, 5, 6, 7, 8, 9]
"foo" <> " " <> "bar" == "foo bar"

This generalizes the idea of a monoid, as it does not require an empty version.

Type Class

An instance of Realm.Semigroup must define Realm.Semigroup.append/2.

Semigroup  [append/2]

Link to this section Summary

Functions

appendenate two data of the same type. These can be chained together an arbitrary number of times. For example

Link to this section Types

Link to this section Functions

appendenate two data of the same type. These can be chained together an arbitrary number of times. For example:

iex> 1 |> append(2) |> append(3)
6
iex> [1, 2, 3]
...> |> append([4, 5, 6])
...> |> append([7, 8, 9])
[1, 2, 3, 4, 5, 6, 7, 8, 9]
iex> "foo" |> append(" ") |> append("bar")
"foo bar"