Funx.Monoid.Utils
Mix.install([
{:funx,
git: "https://github.com/JKWA/funx.git",
branch: "main"
}
])
Utility functions for working with Monoids.
This module provides functions to combine monoidal values using
m_append/3 and m_concat/2.
Function Examples
import Funx.Monoid.Utils
m_append/3
Appends two values within a given monoid.
This function wraps the input values using the provided monoid, applies
the append/2 operation, and then unwraps the result.
Parameters
-
monoid– A monoid struct defining how values should be combined. -
a– The first raw value. -
b– The second raw value.
Examples
alias Funx.Monoid.Sum
m_append(%Sum{}, 3, 5)
m_concat/2
Concatenates a list of values using the given monoid.
This function wraps each value using the provided monoid, folds the list
using the monoid’s identity and append operation, and then unwraps the result.
Parameters
-
monoid– A monoid struct defining how values should be combined. -
values– A list of raw values.
Examples
alias Funx.Monoid.Sum
m_concat(%Sum{}, [1, 2, 3])