1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-08-10 22:31:32 +02:00

fix: add Flap to more monads

Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
Dr. Carsten Leue
2023-10-12 09:48:42 +02:00
parent b434f1fbf4
commit f129297045
11 changed files with 92 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ import (
"sort"
F "github.com/IBM/fp-go/function"
FC "github.com/IBM/fp-go/internal/functor"
G "github.com/IBM/fp-go/internal/record"
Mg "github.com/IBM/fp-go/magma"
Mo "github.com/IBM/fp-go/monoid"
@@ -514,3 +515,11 @@ func FoldMapOrdWithIndex[AS ~map[K]A, K comparable, A, B any](o ord.Ord[K]) func
}
}
}
func MonadFlap[GFAB ~map[K]func(A) B, GB ~map[K]B, K comparable, A, B any](fab GFAB, a A) GB {
return FC.MonadFlap(MonadMap[GFAB, GB], fab, a)
}
func Flap[GFAB ~map[K]func(A) B, GB ~map[K]B, K comparable, A, B any](a A) func(GFAB) GB {
return FC.Flap(MonadMap[GFAB, GB], a)
}

View File

@@ -271,3 +271,11 @@ func KeysOrd[V any, K comparable](o ord.Ord[K]) func(r map[K]V) []K {
func ValuesOrd[V any, K comparable](o ord.Ord[K]) func(r map[K]V) []V {
return G.ValuesOrd[map[K]V, []V, K, V](o)
}
func MonadFlap[B any, K comparable, A any](fab map[K]func(A) B, a A) map[K]B {
return G.MonadFlap[map[K]func(A) B, map[K]B](fab, a)
}
func Flap[B any, K comparable, A any](a A) func(map[K]func(A) B) map[K]B {
return G.Flap[map[K]func(A) B, map[K]B](a)
}