mirror of
https://github.com/IBM/fp-go.git
synced 2025-08-10 22:31:32 +02:00
fix: break cyclic dependencies between IOOption and IOEither
Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
@@ -336,3 +336,14 @@ func MonadFlap[GEAB ~func() ET.Either[E, func(A) B], GEB ~func() ET.Either[E, B]
|
||||
func Flap[GEAB ~func() ET.Either[E, func(A) B], GEB ~func() ET.Either[E, B], E, B, A any](a A) func(GEAB) GEB {
|
||||
return FC.Flap(MonadMap[GEAB, GEB], a)
|
||||
}
|
||||
|
||||
func ToIOOption[GA ~func() O.Option[A], GEA ~func() ET.Either[E, A], E, A any](ioe GEA) GA {
|
||||
return F.Pipe1(
|
||||
ioe,
|
||||
IO.Map[GEA, GA](ET.ToOption[E, A]),
|
||||
)
|
||||
}
|
||||
|
||||
func FromIOOption[GEA ~func() ET.Either[E, A], GA ~func() O.Option[A], E, A any](onNone func() E) func(ioo GA) GEA {
|
||||
return IO.Map[GA, GEA](ET.FromOption[A](onNone))
|
||||
}
|
||||
|
@@ -19,6 +19,7 @@ import (
|
||||
ET "github.com/IBM/fp-go/either"
|
||||
I "github.com/IBM/fp-go/io"
|
||||
G "github.com/IBM/fp-go/ioeither/generic"
|
||||
IOO "github.com/IBM/fp-go/iooption"
|
||||
L "github.com/IBM/fp-go/lazy"
|
||||
O "github.com/IBM/fp-go/option"
|
||||
)
|
||||
@@ -63,6 +64,10 @@ func FromOption[A, E any](onNone func() E) func(o O.Option[A]) IOEither[E, A] {
|
||||
return G.FromOption[IOEither[E, A]](onNone)
|
||||
}
|
||||
|
||||
func FromIOOption[A, E any](onNone func() E) func(o IOO.IOOption[A]) IOEither[E, A] {
|
||||
return G.FromIOOption[IOEither[E, A], IOO.IOOption[A]](onNone)
|
||||
}
|
||||
|
||||
func ChainOptionK[A, B, E any](onNone func() E) func(func(A) O.Option[B]) func(IOEither[E, A]) IOEither[E, B] {
|
||||
return G.ChainOptionK[IOEither[E, A], IOEither[E, B]](onNone)
|
||||
}
|
||||
@@ -266,3 +271,8 @@ func MonadFlap[E, B, A any](fab IOEither[E, func(A) B], a A) IOEither[E, B] {
|
||||
func Flap[E, B, A any](a A) func(IOEither[E, func(A) B]) IOEither[E, B] {
|
||||
return G.Flap[IOEither[E, func(A) B], IOEither[E, B]](a)
|
||||
}
|
||||
|
||||
// ToIOOption converts an [IOEither] to an [IOO.IOOption]
|
||||
func ToIOOption[E, A any](ioe IOEither[E, A]) IOO.IOOption[A] {
|
||||
return G.ToIOOption[IOO.IOOption[A]](ioe)
|
||||
}
|
||||
|
Reference in New Issue
Block a user