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

monoid

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 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 ApplicativeMonoid

func ApplicativeMonoid[A, HKTA, HKTFA any](
	_of func(A) HKTA,
	_map func(HKTA, func(A) func(A) A) HKTFA,
	_ap 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