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:
@@ -21,6 +21,7 @@ import (
|
||||
"github.com/IBM/fp-go/internal/eithert"
|
||||
FE "github.com/IBM/fp-go/internal/fromeither"
|
||||
FR "github.com/IBM/fp-go/internal/fromreader"
|
||||
FC "github.com/IBM/fp-go/internal/functor"
|
||||
"github.com/IBM/fp-go/internal/readert"
|
||||
O "github.com/IBM/fp-go/option"
|
||||
R "github.com/IBM/fp-go/reader/generic"
|
||||
@@ -155,3 +156,11 @@ func Local[GA1 ~func(R1) ET.Either[E, A], GA2 ~func(R2) ET.Either[E, A], R2, R1,
|
||||
func Read[GA ~func(E) ET.Either[E1, A], E, E1, A any](e E) func(GA) ET.Either[E1, A] {
|
||||
return R.Read[GA](e)
|
||||
}
|
||||
|
||||
func MonadFlap[GEFAB ~func(E) ET.Either[L, func(A) B], GEB ~func(E) ET.Either[L, B], L, E, A, B any](fab GEFAB, a A) GEB {
|
||||
return FC.MonadFlap(MonadMap[GEFAB, GEB], fab, a)
|
||||
}
|
||||
|
||||
func Flap[GEFAB ~func(E) ET.Either[L, func(A) B], GEB ~func(E) ET.Either[L, B], L, E, A, B any](a A) func(GEFAB) GEB {
|
||||
return FC.Flap(MonadMap[GEFAB, GEB], a)
|
||||
}
|
||||
|
@@ -143,3 +143,11 @@ func Local[E, A, R2, R1 any](f func(R2) R1) func(ReaderEither[R1, E, A]) ReaderE
|
||||
func Read[E1, A, E any](e E) func(ReaderEither[E, E1, A]) ET.Either[E1, A] {
|
||||
return G.Read[ReaderEither[E, E1, A]](e)
|
||||
}
|
||||
|
||||
func MonadFlap[L, E, A, B any](fab ReaderEither[L, E, func(A) B], a A) ReaderEither[L, E, B] {
|
||||
return G.MonadFlap[ReaderEither[L, E, func(A) B], ReaderEither[L, E, B]](fab, a)
|
||||
}
|
||||
|
||||
func Flap[L, E, B, A any](a A) func(ReaderEither[L, E, func(A) B]) ReaderEither[L, E, B] {
|
||||
return G.Flap[ReaderEither[L, E, func(A) B], ReaderEither[L, E, B]](a)
|
||||
}
|
||||
|
Reference in New Issue
Block a user