Help us shape the future of Go! Take the 2026 Go Developer Survey

monoid

package
v1.0.149 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2024 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConcatAll

func ConcatAll[A any](m Monoid[A]) func([]A) A

ConcatAll concatenates all values using the monoid and the default empty value

func Fold

func Fold[A any](m Monoid[A]) func([]A) A

Fold concatenates all values using the monoid and the default empty value

func GenericConcatAll

func GenericConcatAll[GA ~[]A, A any](m Monoid[A]) func(GA) A

func ToSemigroup added in v1.0.5

func ToSemigroup[A any](m Monoid[A]) S.Semigroup[A]

Types

type Monoid

type Monoid[A any] interface {
	S.Semigroup[A]
	Empty() A
}

func AltMonoid added in v1.0.31

func AltMonoid[HKTA any, LAZYHKTA ~func() HKTA](
	fzero LAZYHKTA,
	falt func(HKTA, LAZYHKTA) HKTA,

) Monoid[HKTA]

func AlternativeMonoid added in v1.0.31

func AlternativeMonoid[A, HKTA, HKTFA any, LAZYHKTA ~func() HKTA](
	fof func(A) HKTA,

	fmap func(HKTA, func(A) func(A) A) HKTFA,
	fap func(HKTFA, HKTA) HKTA,

	falt func(HKTA, LAZYHKTA) HKTA,

	m Monoid[A],

) Monoid[HKTA]

func ApplicativeMonoid

func ApplicativeMonoid[A, HKTA, HKTFA any](
	fof func(A) HKTA,
	fmap func(HKTA, func(A) func(A) A) HKTFA,
	fap func(HKTFA, HKTA) HKTA,

	m Monoid[A],
) Monoid[HKTA]

func FunctionMonoid

func FunctionMonoid[A, B any](m Monoid[B]) Monoid[func(A) B]

FunctionMonoid forms a monoid as long as you can provide a monoid for the codomain.

func MakeMonoid

func MakeMonoid[A any](c func(A, A) A, e A) Monoid[A]

MakeMonoid creates a monoid given a concat function and an empty element

func Reverse

func Reverse[A any](m Monoid[A]) Monoid[A]

Reverse returns the dual of a `Monoid`, obtained by swapping the arguments of `Concat`.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL