Monoid.fz
# This file is part of the Fuzion language implementation.
#
# The Fuzion language implementation is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, version 3 of the License.
#
# The Fuzion language implementation is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License along with The
# Fuzion language implementation. If not, see <https://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------
#
# Tokiwa Software GmbH, Germany
#
# Source code of Fuzion standard library feature monoid
#
# Author: Fridtjof Siebert (siebert@tokiwa.software)
#
# -----------------------------------------------------------------------
# Monoid -- parent feature for monoids
#
# A monoid is an abstraction for a type with an associative operation and
# an identity element. Examples are (integers/infix +/0), (float/infix *,1),
# (string/concat/""), etc.
#
#
public Monoid(public T type /* : property.equatable */) ref
/* NYI: quantor intrinsics not supported yet:
inv
analysis: quantor.for_all3<T,T,T>(
# NYI: infix notation for 2-argument feature
# fun(x, y, z T) => (x ∙ y) ∙ z == x ∙ (y ∙ z)), # associativity
fun(x, y, z T) => eq((op(op(x, y), z)), (op(x, op(y, z))))), # associativity
analysis: quantor.for_all<T>(
# NYI: infix notation for 2-argument feature
# fun(x T) => (x ∙ e) == (e ∙ x) == x) # identity element
fun(x T) => (eq(op(x, e), op(e, x)) &
eq(op(e, x), x))) # identity element
*/
is
# associative operation
#
public infix ∙ (a, b T) T => abstract
# identity element
#
public e T => abstract
# alternative names for infix operators
public op(a, b T) => infix ∙ a b
last changed: 2024-03-07