1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-11-27 22:28:29 +02:00

fix: some performance optimizations

Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
Dr. Carsten Leue
2025-11-05 16:55:19 +01:00
parent 9919b75fe6
commit 8e7fc699a1
25 changed files with 1704 additions and 62 deletions

View File

@@ -20,7 +20,20 @@ import (
"github.com/IBM/fp-go/v2/internal/monad"
)
// Monad returns the monadic operations for an array
// Monad returns the monadic operations for an array.
// This provides a structured way to access all monad operations (Map, Chain, Ap, Of)
// for arrays in a single interface.
//
// The Monad interface is useful when you need to pass monadic operations as parameters
// or when working with generic code that operates on any monad.
//
// Example:
//
// m := array.Monad[int, string]()
// result := m.Chain([]int{1, 2, 3}, func(x int) []string {
// return []string{fmt.Sprintf("%d", x), fmt.Sprintf("%d!", x)}
// })
// // Result: ["1", "1!", "2", "2!", "3", "3!"]
func Monad[A, B any]() monad.Monad[A, B, []A, []B, []func(A) B] {
return G.Monad[A, B, []A, []B, []func(A) B]()
}