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:
@@ -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]()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user