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

foldable

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Foldable

type Foldable[A, B, HKTA any] interface {
	// Reduce folds the structure from left to right using a binary function and initial value.
	Reduce(func(B, A) B, B) func(HKTA) B

	// ReduceRight folds the structure from right to left using a binary function and initial value.
	ReduceRight(func(B, A) B, B) func(HKTA) B

	// FoldMap maps each element to a monoid and combines them using the monoid's operation.
	FoldMap(m M.Monoid[B]) func(func(A) B) func(HKTA) B
}

Foldable represents a data structure that can be folded/reduced to a single value.

Foldable provides operations to collapse a structure containing multiple values into a single summary value by applying a combining function.

Type Parameters:

  • A: The type of elements in the structure
  • B: The type of the accumulated result
  • HKTA: The higher-kinded type containing A

Jump to

Keyboard shortcuts

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