Documentation
¶
Overview ¶
Package ioeither provides the IOEither monad, combining IO effects with Either for error handling.
Fantasy Land Specification ¶
This is a monad transformer combining:
- IO monad: https://github.com/fantasyland/fantasy-land
- Either monad: https://github.com/fantasyland/fantasy-land#either
Implemented Fantasy Land algebras:
- Functor: https://github.com/fantasyland/fantasy-land#functor
- Bifunctor: https://github.com/fantasyland/fantasy-land#bifunctor
- Apply: https://github.com/fantasyland/fantasy-land#apply
- Applicative: https://github.com/fantasyland/fantasy-land#applicative
- Chain: https://github.com/fantasyland/fantasy-land#chain
- Monad: https://github.com/fantasyland/fantasy-land#monad
- Alt: https://github.com/fantasyland/fantasy-land#alt
IOEither[E, A] represents a computation that:
- Performs side effects (IO)
- Can fail with an error of type E or succeed with a value of type A (Either)
This is defined as: IO[Either[E, A]] or func() Either[E, A]
Index ¶
- func ApSeq[B, E, A any](ma IOEither[E, A]) func(IOEither[E, func(A) B]) IOEither[E, B]
- func BiMap[E1, E2, A, B any](f func(E1) E2, g func(A) B) func(IOEither[E1, A]) IOEither[E2, B]
- func ChainLeft[EA, EB, A any](f Kleisli[EB, EA, A]) func(IOEither[EA, A]) IOEither[EB, A]
- func ChainOptionK[A, B, E any](onNone func() E) func(func(A) O.Option[B]) Operator[E, A, B]
- func Eitherize0[F ~func() (R, error), R any](f F) func() IOEither[error, R]
- func Eitherize1[F ~func(T1) (R, error), T1, R any](f F) func(T1) IOEither[error, R]
- func Eitherize10[F ~func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) (R, error), ...](f F) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) IOEither[error, R]
- func Eitherize2[F ~func(T1, T2) (R, error), T1, T2, R any](f F) func(T1, T2) IOEither[error, R]
- func Eitherize3[F ~func(T1, T2, T3) (R, error), T1, T2, T3, R any](f F) func(T1, T2, T3) IOEither[error, R]
- func Eitherize4[F ~func(T1, T2, T3, T4) (R, error), T1, T2, T3, T4, R any](f F) func(T1, T2, T3, T4) IOEither[error, R]
- func Eitherize5[F ~func(T1, T2, T3, T4, T5) (R, error), T1, T2, T3, T4, T5, R any](f F) func(T1, T2, T3, T4, T5) IOEither[error, R]
- func Eitherize6[F ~func(T1, T2, T3, T4, T5, T6) (R, error), T1, T2, T3, T4, T5, T6, R any](f F) func(T1, T2, T3, T4, T5, T6) IOEither[error, R]
- func Eitherize7[F ~func(T1, T2, T3, T4, T5, T6, T7) (R, error), ...](f F) func(T1, T2, T3, T4, T5, T6, T7) IOEither[error, R]
- func Eitherize8[F ~func(T1, T2, T3, T4, T5, T6, T7, T8) (R, error), ...](f F) func(T1, T2, T3, T4, T5, T6, T7, T8) IOEither[error, R]
- func Eitherize9[F ~func(T1, T2, T3, T4, T5, T6, T7, T8, T9) (R, error), ...](f F) func(T1, T2, T3, T4, T5, T6, T7, T8, T9) IOEither[error, R]
- func Eq[E, A any](eq EQ.Eq[Either[E, A]]) EQ.Eq[IOEither[E, A]]
- func Fold[E, A, B any](onLeft func(E) IO[B], onRight io.Kleisli[A, B]) func(IOEither[E, A]) IO[B]
- func FromIOOption[A, E any](onNone func() E) func(o IOO.IOOption[A]) IOEither[E, A]
- func FromOption[A, E any](onNone func() E) func(o O.Option[A]) IOEither[E, A]
- func FromStrictEquals[E, A comparable]() EQ.Eq[IOEither[E, A]]
- func Functor[E, A, B any]() functor.Functor[A, B, IOEither[E, A], IOEither[E, B]]
- func GetOrElse[E, A any](onLeft func(E) IO[A]) func(IOEither[E, A]) IO[A]
- func GetOrElseOf[E, A any](onLeft func(E) A) func(IOEither[E, A]) IO[A]
- func MapLeft[A, E1, E2 any](f func(E1) E2) func(IOEither[E1, A]) IOEither[E2, A]
- func Monad[E, A, B any]() monad.Monad[A, B, IOEither[E, A], IOEither[E, B], IOEither[E, func(A) B]]
- func Pointed[E, A any]() pointed.Pointed[A, IOEither[E, A]]
- func ToIOOption[E, A any](ioe IOEither[E, A]) IOO.IOOption[A]
- func TraverseParTuple1[E error, F1 ~func(A1) IOEither[E, T1], T1, A1 any](f1 F1) func(tuple.Tuple1[A1]) IOEither[E, tuple.Tuple1[T1]]
- func TraverseParTuple10[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10) ...
- func TraverseParTuple2[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2) func(tuple.Tuple2[A1, A2]) IOEither[E, tuple.Tuple2[T1, T2]]
- func TraverseParTuple3[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3) func(tuple.Tuple3[A1, A2, A3]) IOEither[E, tuple.Tuple3[T1, T2, T3]]
- func TraverseParTuple4[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4) func(tuple.Tuple4[A1, A2, A3, A4]) IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]
- func TraverseParTuple5[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5) ...
- func TraverseParTuple6[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6) ...
- func TraverseParTuple7[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7) ...
- func TraverseParTuple8[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8) ...
- func TraverseParTuple9[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9) ...
- func TraverseSeqTuple1[E error, F1 ~func(A1) IOEither[E, T1], T1, A1 any](f1 F1) func(tuple.Tuple1[A1]) IOEither[E, tuple.Tuple1[T1]]
- func TraverseSeqTuple10[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10) ...
- func TraverseSeqTuple2[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2) func(tuple.Tuple2[A1, A2]) IOEither[E, tuple.Tuple2[T1, T2]]
- func TraverseSeqTuple3[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3) func(tuple.Tuple3[A1, A2, A3]) IOEither[E, tuple.Tuple3[T1, T2, T3]]
- func TraverseSeqTuple4[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4) func(tuple.Tuple4[A1, A2, A3, A4]) IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]
- func TraverseSeqTuple5[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5) ...
- func TraverseSeqTuple6[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6) ...
- func TraverseSeqTuple7[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7) ...
- func TraverseSeqTuple8[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8) ...
- func TraverseSeqTuple9[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9) ...
- func TraverseTuple1[E error, F1 ~func(A1) IOEither[E, T1], T1, A1 any](f1 F1) func(tuple.Tuple1[A1]) IOEither[E, tuple.Tuple1[T1]]
- func TraverseTuple10[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10) ...
- func TraverseTuple2[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2) func(tuple.Tuple2[A1, A2]) IOEither[E, tuple.Tuple2[T1, T2]]
- func TraverseTuple3[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3) func(tuple.Tuple3[A1, A2, A3]) IOEither[E, tuple.Tuple3[T1, T2, T3]]
- func TraverseTuple4[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4) func(tuple.Tuple4[A1, A2, A3, A4]) IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]
- func TraverseTuple5[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5) ...
- func TraverseTuple6[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6) ...
- func TraverseTuple7[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7) ...
- func TraverseTuple8[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8) ...
- func TraverseTuple9[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], ...](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9) ...
- func Uneitherize0[F ~func() IOEither[error, R], R any](f F) func() (R, error)
- func Uneitherize1[F ~func(T1) IOEither[error, R], T1, R any](f F) func(T1) (R, error)
- func Uneitherize10[F ~func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) IOEither[error, R], ...](f F) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) (R, error)
- func Uneitherize2[F ~func(T1, T2) IOEither[error, R], T1, T2, R any](f F) func(T1, T2) (R, error)
- func Uneitherize3[F ~func(T1, T2, T3) IOEither[error, R], T1, T2, T3, R any](f F) func(T1, T2, T3) (R, error)
- func Uneitherize4[F ~func(T1, T2, T3, T4) IOEither[error, R], T1, T2, T3, T4, R any](f F) func(T1, T2, T3, T4) (R, error)
- func Uneitherize5[F ~func(T1, T2, T3, T4, T5) IOEither[error, R], T1, T2, T3, T4, T5, R any](f F) func(T1, T2, T3, T4, T5) (R, error)
- func Uneitherize6[F ~func(T1, T2, T3, T4, T5, T6) IOEither[error, R], ...](f F) func(T1, T2, T3, T4, T5, T6) (R, error)
- func Uneitherize7[F ~func(T1, T2, T3, T4, T5, T6, T7) IOEither[error, R], ...](f F) func(T1, T2, T3, T4, T5, T6, T7) (R, error)
- func Uneitherize8[F ~func(T1, T2, T3, T4, T5, T6, T7, T8) IOEither[error, R], ...](f F) func(T1, T2, T3, T4, T5, T6, T7, T8) (R, error)
- func Uneitherize9[F ~func(T1, T2, T3, T4, T5, T6, T7, T8, T9) IOEither[error, R], ...](f F) func(T1, T2, T3, T4, T5, T6, T7, T8, T9) (R, error)
- type Consumer
- type Either
- type IO
- type IOEither
- func Bracket[E, A, B, ANY any](acquire IOEither[E, A], use Kleisli[E, A, B], ...) IOEither[E, B]
- func Defer[E, A any](gen lazy.Lazy[IOEither[E, A]]) IOEither[E, A]
- func Do[E, S any](empty S) IOEither[E, S]
- func Flatten[E, A any](mma IOEither[E, IOEither[E, A]]) IOEither[E, A]
- func FromEither[E, A any](e Either[E, A]) IOEither[E, A]
- func FromIO[E, A any](mr IO[A]) IOEither[E, A]
- func FromImpure[E any](f func()) IOEither[E, any]
- func FromLazy[E, A any](mr lazy.Lazy[A]) IOEither[E, A]
- func Left[A, E any](l E) IOEither[E, A]
- func LeftIO[A, E any](ml IO[E]) IOEither[E, A]
- func Memoize[E, A any](ma IOEither[E, A]) IOEither[E, A]
- func MonadAlt[E, A any](first IOEither[E, A], second lazy.Lazy[IOEither[E, A]]) IOEither[E, A]
- func MonadAp[B, E, A any](mab IOEither[E, func(A) B], ma IOEither[E, A]) IOEither[E, B]
- func MonadApFirst[A, E, B any](first IOEither[E, A], second IOEither[E, B]) IOEither[E, A]
- func MonadApPar[B, E, A any](mab IOEither[E, func(A) B], ma IOEither[E, A]) IOEither[E, B]
- func MonadApSecond[A, E, B any](first IOEither[E, A], second IOEither[E, B]) IOEither[E, B]
- func MonadApSeq[B, E, A any](mab IOEither[E, func(A) B], ma IOEither[E, A]) IOEither[E, B]
- func MonadBiMap[E1, E2, A, B any](fa IOEither[E1, A], f func(E1) E2, g func(A) B) IOEither[E2, B]
- func MonadChain[E, A, B any](fa IOEither[E, A], f Kleisli[E, A, B]) IOEither[E, B]
- func MonadChainEitherK[E, A, B any](ma IOEither[E, A], f either.Kleisli[E, A, B]) IOEither[E, B]
- func MonadChainFirst[E, A, B any](ma IOEither[E, A], f Kleisli[E, A, B]) IOEither[E, A]
- func MonadChainFirstEitherK[A, E, B any](ma IOEither[E, A], f either.Kleisli[E, A, B]) IOEither[E, A]
- func MonadChainFirstIOK[E, A, B any](ma IOEither[E, A], f io.Kleisli[A, B]) IOEither[E, A]
- func MonadChainFirstLeft[A, EA, EB, B any](ma IOEither[EA, A], f Kleisli[EB, EA, B]) IOEither[EA, A]
- func MonadChainIOK[E, A, B any](ma IOEither[E, A], f io.Kleisli[A, B]) IOEither[E, B]
- func MonadChainLeft[EA, EB, A any](fa IOEither[EA, A], f Kleisli[EB, EA, A]) IOEither[EB, A]
- func MonadChainTo[A, E, B any](fa IOEither[E, A], fb IOEither[E, B]) IOEither[E, B]
- func MonadChainToIO[E, A, B any](fa IOEither[E, A], fb IO[B]) IOEither[E, B]
- func MonadFlap[E, B, A any](fab IOEither[E, func(A) B], a A) IOEither[E, B]
- func MonadMap[E, A, B any](fa IOEither[E, A], f func(A) B) IOEither[E, B]
- func MonadMapLeft[A, E1, E2 any](fa IOEither[E1, A], f func(E1) E2) IOEither[E2, A]
- func MonadMapTo[E, A, B any](fa IOEither[E, A], b B) IOEither[E, B]
- func MonadOf[E, A any](r A) IOEither[E, A]
- func MonadTap[E, A, B any](ma IOEither[E, A], f Kleisli[E, A, B]) IOEither[E, A]
- func MonadTapEitherK[A, E, B any](ma IOEither[E, A], f either.Kleisli[E, A, B]) IOEither[E, A]
- func MonadTapIOK[E, A, B any](ma IOEither[E, A], f io.Kleisli[A, B]) IOEither[E, A]
- func MonadTapLeft[A, EA, EB, B any](ma IOEither[EA, A], f Kleisli[EB, EA, B]) IOEither[EA, A]
- func Of[E, A any](r A) IOEither[E, A]
- func Retrying[E, A any](policy R.RetryPolicy, action Kleisli[E, R.RetryStatus, A], ...) IOEither[E, A]
- func Right[E, A any](r A) IOEither[E, A]
- func RightIO[E, A any](mr IO[A]) IOEither[E, A]
- func SequenceArray[E, A any](ma []IOEither[E, A]) IOEither[E, []A]
- func SequenceArrayPar[E, A any](ma []IOEither[E, A]) IOEither[E, []A]
- func SequenceArraySeq[E, A any](ma []IOEither[E, A]) IOEither[E, []A]
- func SequenceParT1[E, T1 any](t1 IOEither[E, T1]) IOEither[E, tuple.Tuple1[T1]]
- func SequenceParT10[E, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ...) IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]
- func SequenceParT2[E, T1, T2 any](t1 IOEither[E, T1], t2 IOEither[E, T2]) IOEither[E, tuple.Tuple2[T1, T2]]
- func SequenceParT3[E, T1, T2, T3 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3]) IOEither[E, tuple.Tuple3[T1, T2, T3]]
- func SequenceParT4[E, T1, T2, T3, T4 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4]) IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]
- func SequenceParT5[E, T1, T2, T3, T4, T5 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ...) IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]
- func SequenceParT6[E, T1, T2, T3, T4, T5, T6 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ...) IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]
- func SequenceParT7[E, T1, T2, T3, T4, T5, T6, T7 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ...) IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]
- func SequenceParT8[E, T1, T2, T3, T4, T5, T6, T7, T8 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ...) IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]
- func SequenceParT9[E, T1, T2, T3, T4, T5, T6, T7, T8, T9 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ...) IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]
- func SequenceParTuple1[E, T1 any](t tuple.Tuple1[IOEither[E, T1]]) IOEither[E, tuple.Tuple1[T1]]
- func SequenceParTuple10[E, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](...) IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]
- func SequenceParTuple2[E, T1, T2 any](t tuple.Tuple2[IOEither[E, T1], IOEither[E, T2]]) IOEither[E, tuple.Tuple2[T1, T2]]
- func SequenceParTuple3[E, T1, T2, T3 any](t tuple.Tuple3[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3]]) IOEither[E, tuple.Tuple3[T1, T2, T3]]
- func SequenceParTuple4[E, T1, T2, T3, T4 any](...) IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]
- func SequenceParTuple5[E, T1, T2, T3, T4, T5 any](...) IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]
- func SequenceParTuple6[E, T1, T2, T3, T4, T5, T6 any](...) IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]
- func SequenceParTuple7[E, T1, T2, T3, T4, T5, T6, T7 any](...) IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]
- func SequenceParTuple8[E, T1, T2, T3, T4, T5, T6, T7, T8 any](...) IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]
- func SequenceParTuple9[E, T1, T2, T3, T4, T5, T6, T7, T8, T9 any](...) IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]
- func SequenceRecord[K comparable, E, A any](ma map[K]IOEither[E, A]) IOEither[E, map[K]A]
- func SequenceRecordPar[K comparable, E, A any](ma map[K]IOEither[E, A]) IOEither[E, map[K]A]
- func SequenceRecordSeq[K comparable, E, A any](ma map[K]IOEither[E, A]) IOEither[E, map[K]A]
- func SequenceSeqT1[E, T1 any](t1 IOEither[E, T1]) IOEither[E, tuple.Tuple1[T1]]
- func SequenceSeqT10[E, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ...) IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]
- func SequenceSeqT2[E, T1, T2 any](t1 IOEither[E, T1], t2 IOEither[E, T2]) IOEither[E, tuple.Tuple2[T1, T2]]
- func SequenceSeqT3[E, T1, T2, T3 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3]) IOEither[E, tuple.Tuple3[T1, T2, T3]]
- func SequenceSeqT4[E, T1, T2, T3, T4 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4]) IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]
- func SequenceSeqT5[E, T1, T2, T3, T4, T5 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ...) IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]
- func SequenceSeqT6[E, T1, T2, T3, T4, T5, T6 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ...) IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]
- func SequenceSeqT7[E, T1, T2, T3, T4, T5, T6, T7 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ...) IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]
- func SequenceSeqT8[E, T1, T2, T3, T4, T5, T6, T7, T8 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ...) IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]
- func SequenceSeqT9[E, T1, T2, T3, T4, T5, T6, T7, T8, T9 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ...) IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]
- func SequenceSeqTuple1[E, T1 any](t tuple.Tuple1[IOEither[E, T1]]) IOEither[E, tuple.Tuple1[T1]]
- func SequenceSeqTuple10[E, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](...) IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]
- func SequenceSeqTuple2[E, T1, T2 any](t tuple.Tuple2[IOEither[E, T1], IOEither[E, T2]]) IOEither[E, tuple.Tuple2[T1, T2]]
- func SequenceSeqTuple3[E, T1, T2, T3 any](t tuple.Tuple3[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3]]) IOEither[E, tuple.Tuple3[T1, T2, T3]]
- func SequenceSeqTuple4[E, T1, T2, T3, T4 any](...) IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]
- func SequenceSeqTuple5[E, T1, T2, T3, T4, T5 any](...) IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]
- func SequenceSeqTuple6[E, T1, T2, T3, T4, T5, T6 any](...) IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]
- func SequenceSeqTuple7[E, T1, T2, T3, T4, T5, T6, T7 any](...) IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]
- func SequenceSeqTuple8[E, T1, T2, T3, T4, T5, T6, T7, T8 any](...) IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]
- func SequenceSeqTuple9[E, T1, T2, T3, T4, T5, T6, T7, T8, T9 any](...) IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]
- func SequenceT1[E, T1 any](t1 IOEither[E, T1]) IOEither[E, tuple.Tuple1[T1]]
- func SequenceT10[E, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ...) IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]
- func SequenceT2[E, T1, T2 any](t1 IOEither[E, T1], t2 IOEither[E, T2]) IOEither[E, tuple.Tuple2[T1, T2]]
- func SequenceT3[E, T1, T2, T3 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3]) IOEither[E, tuple.Tuple3[T1, T2, T3]]
- func SequenceT4[E, T1, T2, T3, T4 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4]) IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]
- func SequenceT5[E, T1, T2, T3, T4, T5 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ...) IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]
- func SequenceT6[E, T1, T2, T3, T4, T5, T6 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ...) IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]
- func SequenceT7[E, T1, T2, T3, T4, T5, T6, T7 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ...) IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]
- func SequenceT8[E, T1, T2, T3, T4, T5, T6, T7, T8 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ...) IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]
- func SequenceT9[E, T1, T2, T3, T4, T5, T6, T7, T8, T9 any](t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ...) IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]
- func SequenceTuple1[E, T1 any](t tuple.Tuple1[IOEither[E, T1]]) IOEither[E, tuple.Tuple1[T1]]
- func SequenceTuple10[E, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](...) IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]
- func SequenceTuple2[E, T1, T2 any](t tuple.Tuple2[IOEither[E, T1], IOEither[E, T2]]) IOEither[E, tuple.Tuple2[T1, T2]]
- func SequenceTuple3[E, T1, T2, T3 any](t tuple.Tuple3[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3]]) IOEither[E, tuple.Tuple3[T1, T2, T3]]
- func SequenceTuple4[E, T1, T2, T3, T4 any](...) IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]
- func SequenceTuple5[E, T1, T2, T3, T4, T5 any](...) IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]
- func SequenceTuple6[E, T1, T2, T3, T4, T5, T6 any](...) IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]
- func SequenceTuple7[E, T1, T2, T3, T4, T5, T6, T7 any](...) IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]
- func SequenceTuple8[E, T1, T2, T3, T4, T5, T6, T7, T8 any](...) IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]
- func SequenceTuple9[E, T1, T2, T3, T4, T5, T6, T7, T8, T9 any](...) IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]
- func Swap[E, A any](val IOEither[E, A]) IOEither[A, E]
- func TryCatch[E, A any](f func() (A, error), onThrow func(error) E) IOEither[E, A]
- func TryCatchError[A any](f func() (A, error)) IOEither[error, A]
- type Kleisli
- func LogJSON[A any](prefix string) Kleisli[error, A, string]
- func TailRec[E, A, B any](f Kleisli[E, A, tailrec.Trampoline[A, B]]) Kleisli[E, A, B]
- func TraverseArray[E, A, B any](f Kleisli[E, A, B]) Kleisli[E, []A, []B]
- func TraverseArrayPar[E, A, B any](f Kleisli[E, A, B]) Kleisli[E, []A, []B]
- func TraverseArraySeq[E, A, B any](f Kleisli[E, A, B]) Kleisli[E, []A, []B]
- func TraverseArrayWithIndex[E, A, B any](f func(int, A) IOEither[E, B]) Kleisli[E, []A, []B]
- func TraverseArrayWithIndexPar[E, A, B any](f func(int, A) IOEither[E, B]) Kleisli[E, []A, []B]
- func TraverseArrayWithIndexSeq[E, A, B any](f func(int, A) IOEither[E, B]) Kleisli[E, []A, []B]
- func TraverseRecord[K comparable, E, A, B any](f Kleisli[E, A, B]) Kleisli[E, map[K]A, map[K]B]
- func TraverseRecordPar[K comparable, E, A, B any](f Kleisli[E, A, B]) Kleisli[E, map[K]A, map[K]B]
- func TraverseRecordSeq[K comparable, E, A, B any](f Kleisli[E, A, B]) Kleisli[E, map[K]A, map[K]B]
- func TraverseRecordWithIndex[K comparable, E, A, B any](f func(K, A) IOEither[E, B]) Kleisli[E, map[K]A, map[K]B]
- func TraverseRecordWithIndexPar[K comparable, E, A, B any](f func(K, A) IOEither[E, B]) Kleisli[E, map[K]A, map[K]B]
- func TraverseRecordWithIndexSeq[K comparable, E, A, B any](f func(K, A) IOEither[E, B]) Kleisli[E, map[K]A, map[K]B]
- func WithResource[A, E, R, ANY any](onCreate IOEither[E, R], onRelease Kleisli[E, R, ANY]) Kleisli[E, Kleisli[E, R, A], A]
- type Monoid
- type Operator
- func After[E, A any](timestamp time.Time) Operator[E, A, A]
- func Alt[E, A any](second lazy.Lazy[IOEither[E, A]]) Operator[E, A, A]
- func Ap[B, E, A any](ma IOEither[E, A]) Operator[E, func(A) B, B]
- func ApFirst[A, E, B any](second IOEither[E, B]) Operator[E, A, A]
- func ApPar[B, E, A any](ma IOEither[E, A]) Operator[E, func(A) B, B]
- func ApS[E, S1, S2, T any](setter func(T) func(S1) S2, fa IOEither[E, T]) Operator[E, S1, S2]
- func ApSL[E, S, T any](lens L.Lens[S, T], fa IOEither[E, T]) Operator[E, S, S]
- func ApSecond[A, E, B any](second IOEither[E, B]) Operator[E, A, B]
- func Bind[E, S1, S2, T any](setter func(T) func(S1) S2, f Kleisli[E, S1, T]) Operator[E, S1, S2]
- func BindL[E, S, T any](lens L.Lens[S, T], f Kleisli[E, T, T]) Operator[E, S, S]
- func BindTo[E, S1, T any](setter func(T) S1) Operator[E, T, S1]
- func Chain[E, A, B any](f Kleisli[E, A, B]) Operator[E, A, B]
- func ChainConsumer[E, A any](c Consumer[A]) Operator[E, A, struct{}]
- func ChainEitherK[E, A, B any](f either.Kleisli[E, A, B]) Operator[E, A, B]
- func ChainFirst[E, A, B any](f Kleisli[E, A, B]) Operator[E, A, A]
- func ChainFirstConsumer[E, A any](c Consumer[A]) Operator[E, A, A]
- func ChainFirstEitherK[A, E, B any](f either.Kleisli[E, A, B]) Operator[E, A, A]
- func ChainFirstIOK[E, A, B any](f io.Kleisli[A, B]) Operator[E, A, A]
- func ChainFirstLeft[A, EA, EB, B any](f Kleisli[EB, EA, B]) Operator[EA, A, A]
- func ChainIOK[E, A, B any](f io.Kleisli[A, B]) Operator[E, A, B]
- func ChainLazyK[E, A, B any](f func(A) lazy.Lazy[B]) Operator[E, A, B]
- func ChainTo[A, E, B any](fb IOEither[E, B]) Operator[E, A, B]
- func ChainToIO[E, A, B any](fb IO[B]) Operator[E, A, B]
- func Delay[E, A any](delay time.Duration) Operator[E, A, A]
- func Flap[E, B, A any](a A) Operator[E, func(A) B, B]
- func Let[E, S1, S2, T any](setter func(T) func(S1) S2, f func(S1) T) Operator[E, S1, S2]
- func LetL[E, S, T any](lens L.Lens[S, T], f func(T) T) Operator[E, S, S]
- func LetTo[E, S1, S2, T any](setter func(T) func(S1) S2, b T) Operator[E, S1, S2]
- func LetToL[E, S, T any](lens L.Lens[S, T], b T) Operator[E, S, S]
- func LogEntryExit[E, A any](name string) Operator[E, A, A]
- func LogEntryExitF[E, A, STARTTOKEN, ANY any](onEntry IO[STARTTOKEN], ...) Operator[E, A, A]
- func Map[E, A, B any](f func(A) B) Operator[E, A, B]
- func MapTo[E, A, B any](b B) Operator[E, A, B]
- func Tap[E, A, B any](f Kleisli[E, A, B]) Operator[E, A, A]
- func TapEitherK[A, E, B any](f either.Kleisli[E, A, B]) Operator[E, A, A]
- func TapIOK[E, A, B any](f io.Kleisli[A, B]) Operator[E, A, A]
- func TapLeft[A, EA, EB, B any](f Kleisli[EB, EA, B]) Operator[EA, A, A]
- func WithLock[E, A any](lock IO[context.CancelFunc]) Operator[E, A, A]
- type Semigroup
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApSeq ¶
func ApSeq[B, E, A any](ma IOEither[E, A]) func(IOEither[E, func(A) B]) IOEither[E, B]
ApSeq applies function and value sequentially
func BiMap ¶
func BiMap[E1, E2, A, B any](f func(E1) E2, g func(A) B) func(IOEither[E1, A]) IOEither[E2, B]
BiMap maps a pair of functions over the two type arguments of the bifunctor.
func ChainLeft ¶
func ChainLeft[EA, EB, A any](f Kleisli[EB, EA, A]) func(IOEither[EA, A]) IOEither[EB, A]
ChainLeft is the curried version of MonadChainLeft. It returns a function that chains a computation on the left (error) side of an IOEither.
This is particularly useful in functional composition pipelines where you want to handle errors by performing another computation that may also fail.
Parameters:
- f: A function that takes an error of type EA and returns an IOEither with error type EB
Returns:
- A function that transforms an IOEither with error type EA to one with error type EB
Example:
// Create a reusable error handler
recoverFromNetworkError := ChainLeft(func(err string) IOEither[string, int] {
if strings.Contains(err, "network") {
return Right[string](0) // return default value
}
return Left[int](err) // propagate other errors
})
result := F.Pipe1(
Left[int]("network timeout"),
recoverFromNetworkError,
)
func ChainOptionK ¶
func Eitherize0 ¶
Eitherize0 converts a function with 1 parameters returning a tuple into a function with 0 parameters returning a [IOEither[error, R]]
func Eitherize1 ¶
Eitherize1 converts a function with 2 parameters returning a tuple into a function with 1 parameters returning a [IOEither[error, R]]
func Eitherize10 ¶
func Eitherize10[F ~func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) (R, error), T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, R any](f F) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) IOEither[error, R]
Eitherize10 converts a function with 11 parameters returning a tuple into a function with 10 parameters returning a [IOEither[error, R]]
func Eitherize2 ¶
Eitherize2 converts a function with 3 parameters returning a tuple into a function with 2 parameters returning a [IOEither[error, R]]
func Eitherize3 ¶
func Eitherize3[F ~func(T1, T2, T3) (R, error), T1, T2, T3, R any](f F) func(T1, T2, T3) IOEither[error, R]
Eitherize3 converts a function with 4 parameters returning a tuple into a function with 3 parameters returning a [IOEither[error, R]]
func Eitherize4 ¶
func Eitherize4[F ~func(T1, T2, T3, T4) (R, error), T1, T2, T3, T4, R any](f F) func(T1, T2, T3, T4) IOEither[error, R]
Eitherize4 converts a function with 5 parameters returning a tuple into a function with 4 parameters returning a [IOEither[error, R]]
func Eitherize5 ¶
func Eitherize5[F ~func(T1, T2, T3, T4, T5) (R, error), T1, T2, T3, T4, T5, R any](f F) func(T1, T2, T3, T4, T5) IOEither[error, R]
Eitherize5 converts a function with 6 parameters returning a tuple into a function with 5 parameters returning a [IOEither[error, R]]
func Eitherize6 ¶
func Eitherize6[F ~func(T1, T2, T3, T4, T5, T6) (R, error), T1, T2, T3, T4, T5, T6, R any](f F) func(T1, T2, T3, T4, T5, T6) IOEither[error, R]
Eitherize6 converts a function with 7 parameters returning a tuple into a function with 6 parameters returning a [IOEither[error, R]]
func Eitherize7 ¶
func Eitherize7[F ~func(T1, T2, T3, T4, T5, T6, T7) (R, error), T1, T2, T3, T4, T5, T6, T7, R any](f F) func(T1, T2, T3, T4, T5, T6, T7) IOEither[error, R]
Eitherize7 converts a function with 8 parameters returning a tuple into a function with 7 parameters returning a [IOEither[error, R]]
func Eitherize8 ¶
func Eitherize8[F ~func(T1, T2, T3, T4, T5, T6, T7, T8) (R, error), T1, T2, T3, T4, T5, T6, T7, T8, R any](f F) func(T1, T2, T3, T4, T5, T6, T7, T8) IOEither[error, R]
Eitherize8 converts a function with 9 parameters returning a tuple into a function with 8 parameters returning a [IOEither[error, R]]
func Eitherize9 ¶
func Eitherize9[F ~func(T1, T2, T3, T4, T5, T6, T7, T8, T9) (R, error), T1, T2, T3, T4, T5, T6, T7, T8, T9, R any](f F) func(T1, T2, T3, T4, T5, T6, T7, T8, T9) IOEither[error, R]
Eitherize9 converts a function with 10 parameters returning a tuple into a function with 9 parameters returning a [IOEither[error, R]]
func FromIOOption ¶
func FromOption ¶
func FromStrictEquals ¶
func FromStrictEquals[E, A comparable]() EQ.Eq[IOEither[E, A]]
FromStrictEquals constructs an [EQ.Eq] from the canonical comparison function
func GetOrElseOf ¶
GetOrElseOf extracts the value or maps the error
func ToIOOption ¶
ToIOOption converts an IOEither to an [IOO.IOOption]
func TraverseParTuple1 ¶
func TraverseParTuple1[E error, F1 ~func(A1) IOEither[E, T1], T1, A1 any](f1 F1) func(tuple.Tuple1[A1]) IOEither[E, tuple.Tuple1[T1]]
TraverseParTuple1 converts a [tuple.Tuple1[A1]] into a [IOEither[E, tuple.Tuple1[T1]]]
func TraverseParTuple10 ¶
func TraverseParTuple10[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], F5 ~func(A5) IOEither[E, T5], F6 ~func(A6) IOEither[E, T6], F7 ~func(A7) IOEither[E, T7], F8 ~func(A8) IOEither[E, T8], F9 ~func(A9) IOEither[E, T9], F10 ~func(A10) IOEither[E, T10], T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10) func(tuple.Tuple10[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10]) IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]
TraverseParTuple10 converts a [tuple.Tuple10[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10]] into a [IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]]
func TraverseParTuple2 ¶
func TraverseParTuple2[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], T1, T2, A1, A2 any](f1 F1, f2 F2) func(tuple.Tuple2[A1, A2]) IOEither[E, tuple.Tuple2[T1, T2]]
TraverseParTuple2 converts a [tuple.Tuple2[A1, A2]] into a [IOEither[E, tuple.Tuple2[T1, T2]]]
func TraverseParTuple3 ¶
func TraverseParTuple3[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], T1, T2, T3, A1, A2, A3 any](f1 F1, f2 F2, f3 F3) func(tuple.Tuple3[A1, A2, A3]) IOEither[E, tuple.Tuple3[T1, T2, T3]]
TraverseParTuple3 converts a [tuple.Tuple3[A1, A2, A3]] into a [IOEither[E, tuple.Tuple3[T1, T2, T3]]]
func TraverseParTuple4 ¶
func TraverseParTuple4[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], T1, T2, T3, T4, A1, A2, A3, A4 any](f1 F1, f2 F2, f3 F3, f4 F4) func(tuple.Tuple4[A1, A2, A3, A4]) IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]
TraverseParTuple4 converts a [tuple.Tuple4[A1, A2, A3, A4]] into a [IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]]
func TraverseParTuple5 ¶
func TraverseParTuple5[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], F5 ~func(A5) IOEither[E, T5], T1, T2, T3, T4, T5, A1, A2, A3, A4, A5 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5) func(tuple.Tuple5[A1, A2, A3, A4, A5]) IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]
TraverseParTuple5 converts a [tuple.Tuple5[A1, A2, A3, A4, A5]] into a [IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]]
func TraverseParTuple6 ¶
func TraverseParTuple6[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], F5 ~func(A5) IOEither[E, T5], F6 ~func(A6) IOEither[E, T6], T1, T2, T3, T4, T5, T6, A1, A2, A3, A4, A5, A6 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6) func(tuple.Tuple6[A1, A2, A3, A4, A5, A6]) IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]
TraverseParTuple6 converts a [tuple.Tuple6[A1, A2, A3, A4, A5, A6]] into a [IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]]
func TraverseParTuple7 ¶
func TraverseParTuple7[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], F5 ~func(A5) IOEither[E, T5], F6 ~func(A6) IOEither[E, T6], F7 ~func(A7) IOEither[E, T7], T1, T2, T3, T4, T5, T6, T7, A1, A2, A3, A4, A5, A6, A7 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7) func(tuple.Tuple7[A1, A2, A3, A4, A5, A6, A7]) IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]
TraverseParTuple7 converts a [tuple.Tuple7[A1, A2, A3, A4, A5, A6, A7]] into a [IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]]
func TraverseParTuple8 ¶
func TraverseParTuple8[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], F5 ~func(A5) IOEither[E, T5], F6 ~func(A6) IOEither[E, T6], F7 ~func(A7) IOEither[E, T7], F8 ~func(A8) IOEither[E, T8], T1, T2, T3, T4, T5, T6, T7, T8, A1, A2, A3, A4, A5, A6, A7, A8 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8) func(tuple.Tuple8[A1, A2, A3, A4, A5, A6, A7, A8]) IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]
TraverseParTuple8 converts a [tuple.Tuple8[A1, A2, A3, A4, A5, A6, A7, A8]] into a [IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]]
func TraverseParTuple9 ¶
func TraverseParTuple9[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], F5 ~func(A5) IOEither[E, T5], F6 ~func(A6) IOEither[E, T6], F7 ~func(A7) IOEither[E, T7], F8 ~func(A8) IOEither[E, T8], F9 ~func(A9) IOEither[E, T9], T1, T2, T3, T4, T5, T6, T7, T8, T9, A1, A2, A3, A4, A5, A6, A7, A8, A9 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9) func(tuple.Tuple9[A1, A2, A3, A4, A5, A6, A7, A8, A9]) IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]
TraverseParTuple9 converts a [tuple.Tuple9[A1, A2, A3, A4, A5, A6, A7, A8, A9]] into a [IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]]
func TraverseSeqTuple1 ¶
func TraverseSeqTuple1[E error, F1 ~func(A1) IOEither[E, T1], T1, A1 any](f1 F1) func(tuple.Tuple1[A1]) IOEither[E, tuple.Tuple1[T1]]
TraverseSeqTuple1 converts a [tuple.Tuple1[A1]] into a [IOEither[E, tuple.Tuple1[T1]]]
func TraverseSeqTuple10 ¶
func TraverseSeqTuple10[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], F5 ~func(A5) IOEither[E, T5], F6 ~func(A6) IOEither[E, T6], F7 ~func(A7) IOEither[E, T7], F8 ~func(A8) IOEither[E, T8], F9 ~func(A9) IOEither[E, T9], F10 ~func(A10) IOEither[E, T10], T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10) func(tuple.Tuple10[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10]) IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]
TraverseSeqTuple10 converts a [tuple.Tuple10[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10]] into a [IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]]
func TraverseSeqTuple2 ¶
func TraverseSeqTuple2[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], T1, T2, A1, A2 any](f1 F1, f2 F2) func(tuple.Tuple2[A1, A2]) IOEither[E, tuple.Tuple2[T1, T2]]
TraverseSeqTuple2 converts a [tuple.Tuple2[A1, A2]] into a [IOEither[E, tuple.Tuple2[T1, T2]]]
func TraverseSeqTuple3 ¶
func TraverseSeqTuple3[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], T1, T2, T3, A1, A2, A3 any](f1 F1, f2 F2, f3 F3) func(tuple.Tuple3[A1, A2, A3]) IOEither[E, tuple.Tuple3[T1, T2, T3]]
TraverseSeqTuple3 converts a [tuple.Tuple3[A1, A2, A3]] into a [IOEither[E, tuple.Tuple3[T1, T2, T3]]]
func TraverseSeqTuple4 ¶
func TraverseSeqTuple4[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], T1, T2, T3, T4, A1, A2, A3, A4 any](f1 F1, f2 F2, f3 F3, f4 F4) func(tuple.Tuple4[A1, A2, A3, A4]) IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]
TraverseSeqTuple4 converts a [tuple.Tuple4[A1, A2, A3, A4]] into a [IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]]
func TraverseSeqTuple5 ¶
func TraverseSeqTuple5[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], F5 ~func(A5) IOEither[E, T5], T1, T2, T3, T4, T5, A1, A2, A3, A4, A5 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5) func(tuple.Tuple5[A1, A2, A3, A4, A5]) IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]
TraverseSeqTuple5 converts a [tuple.Tuple5[A1, A2, A3, A4, A5]] into a [IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]]
func TraverseSeqTuple6 ¶
func TraverseSeqTuple6[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], F5 ~func(A5) IOEither[E, T5], F6 ~func(A6) IOEither[E, T6], T1, T2, T3, T4, T5, T6, A1, A2, A3, A4, A5, A6 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6) func(tuple.Tuple6[A1, A2, A3, A4, A5, A6]) IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]
TraverseSeqTuple6 converts a [tuple.Tuple6[A1, A2, A3, A4, A5, A6]] into a [IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]]
func TraverseSeqTuple7 ¶
func TraverseSeqTuple7[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], F5 ~func(A5) IOEither[E, T5], F6 ~func(A6) IOEither[E, T6], F7 ~func(A7) IOEither[E, T7], T1, T2, T3, T4, T5, T6, T7, A1, A2, A3, A4, A5, A6, A7 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7) func(tuple.Tuple7[A1, A2, A3, A4, A5, A6, A7]) IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]
TraverseSeqTuple7 converts a [tuple.Tuple7[A1, A2, A3, A4, A5, A6, A7]] into a [IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]]
func TraverseSeqTuple8 ¶
func TraverseSeqTuple8[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], F5 ~func(A5) IOEither[E, T5], F6 ~func(A6) IOEither[E, T6], F7 ~func(A7) IOEither[E, T7], F8 ~func(A8) IOEither[E, T8], T1, T2, T3, T4, T5, T6, T7, T8, A1, A2, A3, A4, A5, A6, A7, A8 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8) func(tuple.Tuple8[A1, A2, A3, A4, A5, A6, A7, A8]) IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]
TraverseSeqTuple8 converts a [tuple.Tuple8[A1, A2, A3, A4, A5, A6, A7, A8]] into a [IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]]
func TraverseSeqTuple9 ¶
func TraverseSeqTuple9[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], F5 ~func(A5) IOEither[E, T5], F6 ~func(A6) IOEither[E, T6], F7 ~func(A7) IOEither[E, T7], F8 ~func(A8) IOEither[E, T8], F9 ~func(A9) IOEither[E, T9], T1, T2, T3, T4, T5, T6, T7, T8, T9, A1, A2, A3, A4, A5, A6, A7, A8, A9 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9) func(tuple.Tuple9[A1, A2, A3, A4, A5, A6, A7, A8, A9]) IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]
TraverseSeqTuple9 converts a [tuple.Tuple9[A1, A2, A3, A4, A5, A6, A7, A8, A9]] into a [IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]]
func TraverseTuple1 ¶
func TraverseTuple1[E error, F1 ~func(A1) IOEither[E, T1], T1, A1 any](f1 F1) func(tuple.Tuple1[A1]) IOEither[E, tuple.Tuple1[T1]]
TraverseTuple1 converts a [tuple.Tuple1[A1]] into a [IOEither[E, tuple.Tuple1[T1]]]
func TraverseTuple10 ¶
func TraverseTuple10[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], F5 ~func(A5) IOEither[E, T5], F6 ~func(A6) IOEither[E, T6], F7 ~func(A7) IOEither[E, T7], F8 ~func(A8) IOEither[E, T8], F9 ~func(A9) IOEither[E, T9], F10 ~func(A10) IOEither[E, T10], T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10) func(tuple.Tuple10[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10]) IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]
TraverseTuple10 converts a [tuple.Tuple10[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10]] into a [IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]]
func TraverseTuple2 ¶
func TraverseTuple2[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], T1, T2, A1, A2 any](f1 F1, f2 F2) func(tuple.Tuple2[A1, A2]) IOEither[E, tuple.Tuple2[T1, T2]]
TraverseTuple2 converts a [tuple.Tuple2[A1, A2]] into a [IOEither[E, tuple.Tuple2[T1, T2]]]
func TraverseTuple3 ¶
func TraverseTuple3[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], T1, T2, T3, A1, A2, A3 any](f1 F1, f2 F2, f3 F3) func(tuple.Tuple3[A1, A2, A3]) IOEither[E, tuple.Tuple3[T1, T2, T3]]
TraverseTuple3 converts a [tuple.Tuple3[A1, A2, A3]] into a [IOEither[E, tuple.Tuple3[T1, T2, T3]]]
func TraverseTuple4 ¶
func TraverseTuple4[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], T1, T2, T3, T4, A1, A2, A3, A4 any](f1 F1, f2 F2, f3 F3, f4 F4) func(tuple.Tuple4[A1, A2, A3, A4]) IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]
TraverseTuple4 converts a [tuple.Tuple4[A1, A2, A3, A4]] into a [IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]]
func TraverseTuple5 ¶
func TraverseTuple5[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], F5 ~func(A5) IOEither[E, T5], T1, T2, T3, T4, T5, A1, A2, A3, A4, A5 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5) func(tuple.Tuple5[A1, A2, A3, A4, A5]) IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]
TraverseTuple5 converts a [tuple.Tuple5[A1, A2, A3, A4, A5]] into a [IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]]
func TraverseTuple6 ¶
func TraverseTuple6[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], F5 ~func(A5) IOEither[E, T5], F6 ~func(A6) IOEither[E, T6], T1, T2, T3, T4, T5, T6, A1, A2, A3, A4, A5, A6 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6) func(tuple.Tuple6[A1, A2, A3, A4, A5, A6]) IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]
TraverseTuple6 converts a [tuple.Tuple6[A1, A2, A3, A4, A5, A6]] into a [IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]]
func TraverseTuple7 ¶
func TraverseTuple7[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], F5 ~func(A5) IOEither[E, T5], F6 ~func(A6) IOEither[E, T6], F7 ~func(A7) IOEither[E, T7], T1, T2, T3, T4, T5, T6, T7, A1, A2, A3, A4, A5, A6, A7 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7) func(tuple.Tuple7[A1, A2, A3, A4, A5, A6, A7]) IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]
TraverseTuple7 converts a [tuple.Tuple7[A1, A2, A3, A4, A5, A6, A7]] into a [IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]]
func TraverseTuple8 ¶
func TraverseTuple8[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], F5 ~func(A5) IOEither[E, T5], F6 ~func(A6) IOEither[E, T6], F7 ~func(A7) IOEither[E, T7], F8 ~func(A8) IOEither[E, T8], T1, T2, T3, T4, T5, T6, T7, T8, A1, A2, A3, A4, A5, A6, A7, A8 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8) func(tuple.Tuple8[A1, A2, A3, A4, A5, A6, A7, A8]) IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]
TraverseTuple8 converts a [tuple.Tuple8[A1, A2, A3, A4, A5, A6, A7, A8]] into a [IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]]
func TraverseTuple9 ¶
func TraverseTuple9[E error, F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], F5 ~func(A5) IOEither[E, T5], F6 ~func(A6) IOEither[E, T6], F7 ~func(A7) IOEither[E, T7], F8 ~func(A8) IOEither[E, T8], F9 ~func(A9) IOEither[E, T9], T1, T2, T3, T4, T5, T6, T7, T8, T9, A1, A2, A3, A4, A5, A6, A7, A8, A9 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9) func(tuple.Tuple9[A1, A2, A3, A4, A5, A6, A7, A8, A9]) IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]
TraverseTuple9 converts a [tuple.Tuple9[A1, A2, A3, A4, A5, A6, A7, A8, A9]] into a [IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]]
func Uneitherize0 ¶
Uneitherize0 converts a function with 1 parameters returning a tuple into a function with 0 parameters returning a [IOEither[error, R]]
func Uneitherize1 ¶
Uneitherize1 converts a function with 2 parameters returning a tuple into a function with 1 parameters returning a [IOEither[error, R]]
func Uneitherize10 ¶
func Uneitherize10[F ~func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) IOEither[error, R], T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, R any](f F) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) (R, error)
Uneitherize10 converts a function with 11 parameters returning a tuple into a function with 10 parameters returning a [IOEither[error, R]]
func Uneitherize2 ¶
Uneitherize2 converts a function with 3 parameters returning a tuple into a function with 2 parameters returning a [IOEither[error, R]]
func Uneitherize3 ¶
func Uneitherize3[F ~func(T1, T2, T3) IOEither[error, R], T1, T2, T3, R any](f F) func(T1, T2, T3) (R, error)
Uneitherize3 converts a function with 4 parameters returning a tuple into a function with 3 parameters returning a [IOEither[error, R]]
func Uneitherize4 ¶
func Uneitherize4[F ~func(T1, T2, T3, T4) IOEither[error, R], T1, T2, T3, T4, R any](f F) func(T1, T2, T3, T4) (R, error)
Uneitherize4 converts a function with 5 parameters returning a tuple into a function with 4 parameters returning a [IOEither[error, R]]
func Uneitherize5 ¶
func Uneitherize5[F ~func(T1, T2, T3, T4, T5) IOEither[error, R], T1, T2, T3, T4, T5, R any](f F) func(T1, T2, T3, T4, T5) (R, error)
Uneitherize5 converts a function with 6 parameters returning a tuple into a function with 5 parameters returning a [IOEither[error, R]]
func Uneitherize6 ¶
func Uneitherize6[F ~func(T1, T2, T3, T4, T5, T6) IOEither[error, R], T1, T2, T3, T4, T5, T6, R any](f F) func(T1, T2, T3, T4, T5, T6) (R, error)
Uneitherize6 converts a function with 7 parameters returning a tuple into a function with 6 parameters returning a [IOEither[error, R]]
func Uneitherize7 ¶
func Uneitherize7[F ~func(T1, T2, T3, T4, T5, T6, T7) IOEither[error, R], T1, T2, T3, T4, T5, T6, T7, R any](f F) func(T1, T2, T3, T4, T5, T6, T7) (R, error)
Uneitherize7 converts a function with 8 parameters returning a tuple into a function with 7 parameters returning a [IOEither[error, R]]
func Uneitherize8 ¶
func Uneitherize8[F ~func(T1, T2, T3, T4, T5, T6, T7, T8) IOEither[error, R], T1, T2, T3, T4, T5, T6, T7, T8, R any](f F) func(T1, T2, T3, T4, T5, T6, T7, T8) (R, error)
Uneitherize8 converts a function with 9 parameters returning a tuple into a function with 8 parameters returning a [IOEither[error, R]]
func Uneitherize9 ¶
func Uneitherize9[F ~func(T1, T2, T3, T4, T5, T6, T7, T8, T9) IOEither[error, R], T1, T2, T3, T4, T5, T6, T7, T8, T9, R any](f F) func(T1, T2, T3, T4, T5, T6, T7, T8, T9) (R, error)
Uneitherize9 converts a function with 10 parameters returning a tuple into a function with 9 parameters returning a [IOEither[error, R]]
Types ¶
type IOEither ¶
IOEither represents a synchronous computation that may fail refer to [https://andywhite.xyz/posts/2021-01-27-rte-foundations/#ioeitherlte-agt] for more details
Example (Creation) ¶
// Build an IOEither
leftValue := Left[string](fmt.Errorf("some error"))
rightValue := Right[error]("value")
// Convert from Either
eitherValue := E.Of[error](42)
ioFromEither := FromEither(eitherValue)
// some predicate
isEven := func(num int) (int, error) {
if num%2 == 0 {
return num, nil
}
return 0, fmt.Errorf("%d is an odd number", num)
}
fromEven := Eitherize1(isEven)
leftFromPred := fromEven(3)
rightFromPred := fromEven(4)
fmt.Println(leftValue())
fmt.Println(rightValue())
fmt.Println(ioFromEither())
fmt.Println(leftFromPred())
fmt.Println(rightFromPred())
Output: Left[*errors.errorString](some error) Right[string](value) Right[int](42) Left[*errors.errorString](3 is an odd number) Right[int](4)
Example (Do) ¶
foo := Of[error]("foo")
bar := Of[error](1)
// quux consumes the state of three bindings and returns an [IO] instead of an [IOEither]
quux := func(t T.Tuple3[string, int, string]) IO[any] {
return io.FromImpure(func() {
log.Printf("t1: %s, t2: %d, t3: %s", t.F1, t.F2, t.F3)
})
}
transform := func(t T.Tuple3[string, int, string]) int {
return len(t.F1) + t.F2 + len(t.F3)
}
b := F.Pipe5(
foo,
BindTo[error](T.Of[string]),
ApS(T.Push1[string, int], bar),
Bind(T.Push2[string, int, string], func(t T.Tuple2[string, int]) IOEither[error, string] {
return Of[error](fmt.Sprintf("%s%d", t.F1, t.F2))
}),
ChainFirstIOK[error](quux),
Map[error](transform),
)
fmt.Println(b())
Output: Right[int](8)
Example (Extraction) ¶
// IOEither someIOEither := Right[error](42) eitherValue := someIOEither() // E.Right(42) value := E.GetOrElse(F.Constant1[error](0))(eitherValue) // 42 // Or more directly infaillibleIO := GetOrElse(F.Constant1[error](io.Of(0)))(someIOEither) // => io.Right(42) valueFromIO := infaillibleIO() // => 42 fmt.Println(eitherValue) fmt.Println(value) fmt.Println(valueFromIO)
Output: Right[int](42) 42 42
func Bracket ¶
func Bracket[E, A, B, ANY any]( acquire IOEither[E, A], use Kleisli[E, A, B], release func(A, Either[E, B]) IOEither[E, ANY], ) IOEither[E, B]
Bracket makes sure that a resource is cleaned up in the event of an error. The release action is called regardless of whether the body action returns and error or not.
func Do ¶
func Do[E, S any]( empty S, ) IOEither[E, S]
Do creates an empty context of type [S] to be used with the Bind operation. This is the starting point for do-notation style composition.
Example:
type State struct {
User User
Posts []Post
}
result := ioeither.Do[error](State{})
func FromEither ¶
func FromEither[E, A any](e Either[E, A]) IOEither[E, A]
func FromIO ¶
FromIO creates an IOEither from an IO instance, invoking IO for each invocation of IOEither
func FromImpure ¶
FromImpure converts a side effect without a return value into a side effect that returns any
func FromLazy ¶
FromLazy creates an IOEither from a [Lazy] instance, invoking [Lazy] for each invocation of IOEither
func MonadAp ¶
func MonadAp[B, E, A any](mab IOEither[E, func(A) B], ma IOEither[E, A]) IOEither[E, B]
func MonadApFirst ¶
func MonadApFirst[A, E, B any](first IOEither[E, A], second IOEither[E, B]) IOEither[E, A]
MonadApFirst combines two effectful actions, keeping only the result of the first.
func MonadApPar ¶
func MonadApPar[B, E, A any](mab IOEither[E, func(A) B], ma IOEither[E, A]) IOEither[E, B]
func MonadApSecond ¶
func MonadApSecond[A, E, B any](first IOEither[E, A], second IOEither[E, B]) IOEither[E, B]
MonadApSecond combines two effectful actions, keeping only the result of the second.
func MonadApSeq ¶
func MonadApSeq[B, E, A any](mab IOEither[E, func(A) B], ma IOEither[E, A]) IOEither[E, B]
func MonadBiMap ¶
func MonadBiMap[E1, E2, A, B any](fa IOEither[E1, A], f func(E1) E2, g func(A) B) IOEither[E2, B]
func MonadChain ¶
func MonadChain[E, A, B any](fa IOEither[E, A], f Kleisli[E, A, B]) IOEither[E, B]
func MonadChainEitherK ¶
func MonadChainFirst ¶
func MonadChainFirst[E, A, B any](ma IOEither[E, A], f Kleisli[E, A, B]) IOEither[E, A]
MonadChainFirst runs the IOEither monad returned by the function but returns the result of the original monad
func MonadChainFirstEitherK ¶
func MonadChainFirstIOK ¶
MonadChainFirstIOK runs IO the monad returned by the function but returns the result of the original monad
func MonadChainFirstLeft ¶
func MonadChainFirstLeft[A, EA, EB, B any](ma IOEither[EA, A], f Kleisli[EB, EA, B]) IOEither[EA, A]
MonadChainFirstLeft chains a computation on the left (error) side but always returns the original error. If the input is a Left value, it applies the function f to the error and executes the resulting computation, but always returns the original Left error regardless of what f returns (Left or Right). If the input is a Right value, it passes through unchanged without calling f.
This is useful for side effects on errors (like logging or metrics) where you want to perform an action when an error occurs but always propagate the original error, ensuring the error path is preserved.
Parameters:
- ma: The input IOEither that may contain an error of type EA
- f: A function that takes an error of type EA and returns an IOEither (typically for side effects)
Returns:
- An IOEither with the original error preserved if input was Left, or the original Right value
Example:
// Log errors but always preserve the original error
result := MonadChainFirstLeft(
Left[int]("database error"),
func(err string) IOEither[string, int] {
return FromIO[string](func() int {
log.Printf("Error occurred: %s", err)
return 0
})
},
)
// result will always be Left("database error"), even though f returns Right
func MonadChainIOK ¶
func MonadChainLeft ¶
func MonadChainLeft[EA, EB, A any](fa IOEither[EA, A], f Kleisli[EB, EA, A]) IOEither[EB, A]
MonadChainLeft chains a computation on the left (error) side of an IOEither. If the input is a Left value, it applies the function f to transform the error and potentially change the error type from EA to EB. If the input is a Right value, it passes through unchanged.
This is useful for error recovery or error transformation scenarios where you want to handle errors by performing another computation that may also fail.
Parameters:
- fa: The input IOEither that may contain an error of type EA
- f: A function that takes an error of type EA and returns an IOEither with error type EB
Returns:
- An IOEither with the potentially transformed error type EB
Example:
// Recover from a specific error by trying an alternative computation
result := MonadChainLeft(
Left[int]("network error"),
func(err string) IOEither[string, int] {
if err == "network error" {
return Right[string](42) // recover with default value
}
return Left[int]("unrecoverable: " + err)
},
)
func MonadChainTo ¶
func MonadChainTo[A, E, B any](fa IOEither[E, A], fb IOEither[E, B]) IOEither[E, B]
MonadChainTo composes to the second monad ignoring the return value of the first
func MonadChainToIO ¶
func MonadMapLeft ¶
func MonadMapLeft[A, E1, E2 any](fa IOEither[E1, A], f func(E1) E2) IOEither[E2, A]
func MonadMapTo ¶
func MonadMapTo[E, A, B any](fa IOEither[E, A], b B) IOEither[E, B]
func MonadTapEitherK ¶
func MonadTapIOK ¶
MonadChainFirstIOK runs IO the monad returned by the function but returns the result of the original monad
func MonadTapLeft ¶
func MonadTapLeft[A, EA, EB, B any](ma IOEither[EA, A], f Kleisli[EB, EA, B]) IOEither[EA, A]
func Retrying ¶
func Retrying[E, A any]( policy R.RetryPolicy, action Kleisli[E, R.RetryStatus, A], check func(Either[E, A]) bool, ) IOEither[E, A]
Retrying will retry the actions according to the check policy
policy - refers to the retry policy action - converts a status into an operation to be executed check - checks if the result of the action needs to be retried
func SequenceArray ¶
func SequenceArray[E, A any](ma []IOEither[E, A]) IOEither[E, []A]
SequenceArray converts a homogeneous sequence of either into an either of sequence
func SequenceArrayPar ¶
func SequenceArrayPar[E, A any](ma []IOEither[E, A]) IOEither[E, []A]
SequenceArrayPar converts a homogeneous Paruence of either into an either of Paruence
func SequenceArraySeq ¶
func SequenceArraySeq[E, A any](ma []IOEither[E, A]) IOEither[E, []A]
SequenceArraySeq converts a homogeneous sequence of either into an either of sequence
func SequenceParT1 ¶
SequenceParT1 converts 1 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple1[T1]]]
func SequenceParT10 ¶
func SequenceParT10[E, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], t5 IOEither[E, T5], t6 IOEither[E, T6], t7 IOEither[E, T7], t8 IOEither[E, T8], t9 IOEither[E, T9], t10 IOEither[E, T10], ) IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]
SequenceParT10 converts 10 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]]
func SequenceParT2 ¶
func SequenceParT2[E, T1, T2 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], ) IOEither[E, tuple.Tuple2[T1, T2]]
SequenceParT2 converts 2 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple2[T1, T2]]]
func SequenceParT3 ¶
func SequenceParT3[E, T1, T2, T3 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], ) IOEither[E, tuple.Tuple3[T1, T2, T3]]
SequenceParT3 converts 3 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple3[T1, T2, T3]]]
func SequenceParT4 ¶
func SequenceParT4[E, T1, T2, T3, T4 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ) IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]
SequenceParT4 converts 4 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]]
func SequenceParT5 ¶
func SequenceParT5[E, T1, T2, T3, T4, T5 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], t5 IOEither[E, T5], ) IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]
SequenceParT5 converts 5 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]]
func SequenceParT6 ¶
func SequenceParT6[E, T1, T2, T3, T4, T5, T6 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], t5 IOEither[E, T5], t6 IOEither[E, T6], ) IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]
SequenceParT6 converts 6 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]]
func SequenceParT7 ¶
func SequenceParT7[E, T1, T2, T3, T4, T5, T6, T7 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], t5 IOEither[E, T5], t6 IOEither[E, T6], t7 IOEither[E, T7], ) IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]
SequenceParT7 converts 7 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]]
func SequenceParT8 ¶
func SequenceParT8[E, T1, T2, T3, T4, T5, T6, T7, T8 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], t5 IOEither[E, T5], t6 IOEither[E, T6], t7 IOEither[E, T7], t8 IOEither[E, T8], ) IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]
SequenceParT8 converts 8 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]]
func SequenceParT9 ¶
func SequenceParT9[E, T1, T2, T3, T4, T5, T6, T7, T8, T9 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], t5 IOEither[E, T5], t6 IOEither[E, T6], t7 IOEither[E, T7], t8 IOEither[E, T8], t9 IOEither[E, T9], ) IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]
SequenceParT9 converts 9 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]]
func SequenceParTuple1 ¶
SequenceParTuple1 converts a [tuple.Tuple1[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple1[T1]]]
func SequenceParTuple10 ¶
func SequenceParTuple10[E, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](t tuple.Tuple10[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5], IOEither[E, T6], IOEither[E, T7], IOEither[E, T8], IOEither[E, T9], IOEither[E, T10]]) IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]
SequenceParTuple10 converts a [tuple.Tuple10[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]]
func SequenceParTuple2 ¶
func SequenceParTuple2[E, T1, T2 any](t tuple.Tuple2[IOEither[E, T1], IOEither[E, T2]]) IOEither[E, tuple.Tuple2[T1, T2]]
SequenceParTuple2 converts a [tuple.Tuple2[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple2[T1, T2]]]
func SequenceParTuple3 ¶
func SequenceParTuple3[E, T1, T2, T3 any](t tuple.Tuple3[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3]]) IOEither[E, tuple.Tuple3[T1, T2, T3]]
SequenceParTuple3 converts a [tuple.Tuple3[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple3[T1, T2, T3]]]
func SequenceParTuple4 ¶
func SequenceParTuple4[E, T1, T2, T3, T4 any](t tuple.Tuple4[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4]]) IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]
SequenceParTuple4 converts a [tuple.Tuple4[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]]
func SequenceParTuple5 ¶
func SequenceParTuple5[E, T1, T2, T3, T4, T5 any](t tuple.Tuple5[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5]]) IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]
SequenceParTuple5 converts a [tuple.Tuple5[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]]
func SequenceParTuple6 ¶
func SequenceParTuple6[E, T1, T2, T3, T4, T5, T6 any](t tuple.Tuple6[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5], IOEither[E, T6]]) IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]
SequenceParTuple6 converts a [tuple.Tuple6[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]]
func SequenceParTuple7 ¶
func SequenceParTuple7[E, T1, T2, T3, T4, T5, T6, T7 any](t tuple.Tuple7[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5], IOEither[E, T6], IOEither[E, T7]]) IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]
SequenceParTuple7 converts a [tuple.Tuple7[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]]
func SequenceParTuple8 ¶
func SequenceParTuple8[E, T1, T2, T3, T4, T5, T6, T7, T8 any](t tuple.Tuple8[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5], IOEither[E, T6], IOEither[E, T7], IOEither[E, T8]]) IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]
SequenceParTuple8 converts a [tuple.Tuple8[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]]
func SequenceParTuple9 ¶
func SequenceParTuple9[E, T1, T2, T3, T4, T5, T6, T7, T8, T9 any](t tuple.Tuple9[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5], IOEither[E, T6], IOEither[E, T7], IOEither[E, T8], IOEither[E, T9]]) IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]
SequenceParTuple9 converts a [tuple.Tuple9[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]]
func SequenceRecord ¶
func SequenceRecord[K comparable, E, A any](ma map[K]IOEither[E, A]) IOEither[E, map[K]A]
SequenceRecord converts a homogeneous sequence of either into an either of sequence
func SequenceRecordPar ¶
func SequenceRecordPar[K comparable, E, A any](ma map[K]IOEither[E, A]) IOEither[E, map[K]A]
SequenceRecordPar converts a homogeneous Paruence of either into an either of Paruence
func SequenceRecordSeq ¶
func SequenceRecordSeq[K comparable, E, A any](ma map[K]IOEither[E, A]) IOEither[E, map[K]A]
SequenceRecordSeq converts a homogeneous sequence of either into an either of sequence
func SequenceSeqT1 ¶
SequenceSeqT1 converts 1 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple1[T1]]]
func SequenceSeqT10 ¶
func SequenceSeqT10[E, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], t5 IOEither[E, T5], t6 IOEither[E, T6], t7 IOEither[E, T7], t8 IOEither[E, T8], t9 IOEither[E, T9], t10 IOEither[E, T10], ) IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]
SequenceSeqT10 converts 10 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]]
func SequenceSeqT2 ¶
func SequenceSeqT2[E, T1, T2 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], ) IOEither[E, tuple.Tuple2[T1, T2]]
SequenceSeqT2 converts 2 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple2[T1, T2]]]
func SequenceSeqT3 ¶
func SequenceSeqT3[E, T1, T2, T3 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], ) IOEither[E, tuple.Tuple3[T1, T2, T3]]
SequenceSeqT3 converts 3 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple3[T1, T2, T3]]]
func SequenceSeqT4 ¶
func SequenceSeqT4[E, T1, T2, T3, T4 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ) IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]
SequenceSeqT4 converts 4 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]]
func SequenceSeqT5 ¶
func SequenceSeqT5[E, T1, T2, T3, T4, T5 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], t5 IOEither[E, T5], ) IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]
SequenceSeqT5 converts 5 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]]
func SequenceSeqT6 ¶
func SequenceSeqT6[E, T1, T2, T3, T4, T5, T6 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], t5 IOEither[E, T5], t6 IOEither[E, T6], ) IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]
SequenceSeqT6 converts 6 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]]
func SequenceSeqT7 ¶
func SequenceSeqT7[E, T1, T2, T3, T4, T5, T6, T7 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], t5 IOEither[E, T5], t6 IOEither[E, T6], t7 IOEither[E, T7], ) IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]
SequenceSeqT7 converts 7 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]]
func SequenceSeqT8 ¶
func SequenceSeqT8[E, T1, T2, T3, T4, T5, T6, T7, T8 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], t5 IOEither[E, T5], t6 IOEither[E, T6], t7 IOEither[E, T7], t8 IOEither[E, T8], ) IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]
SequenceSeqT8 converts 8 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]]
func SequenceSeqT9 ¶
func SequenceSeqT9[E, T1, T2, T3, T4, T5, T6, T7, T8, T9 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], t5 IOEither[E, T5], t6 IOEither[E, T6], t7 IOEither[E, T7], t8 IOEither[E, T8], t9 IOEither[E, T9], ) IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]
SequenceSeqT9 converts 9 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]]
func SequenceSeqTuple1 ¶
SequenceSeqTuple1 converts a [tuple.Tuple1[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple1[T1]]]
func SequenceSeqTuple10 ¶
func SequenceSeqTuple10[E, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](t tuple.Tuple10[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5], IOEither[E, T6], IOEither[E, T7], IOEither[E, T8], IOEither[E, T9], IOEither[E, T10]]) IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]
SequenceSeqTuple10 converts a [tuple.Tuple10[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]]
func SequenceSeqTuple2 ¶
func SequenceSeqTuple2[E, T1, T2 any](t tuple.Tuple2[IOEither[E, T1], IOEither[E, T2]]) IOEither[E, tuple.Tuple2[T1, T2]]
SequenceSeqTuple2 converts a [tuple.Tuple2[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple2[T1, T2]]]
func SequenceSeqTuple3 ¶
func SequenceSeqTuple3[E, T1, T2, T3 any](t tuple.Tuple3[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3]]) IOEither[E, tuple.Tuple3[T1, T2, T3]]
SequenceSeqTuple3 converts a [tuple.Tuple3[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple3[T1, T2, T3]]]
func SequenceSeqTuple4 ¶
func SequenceSeqTuple4[E, T1, T2, T3, T4 any](t tuple.Tuple4[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4]]) IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]
SequenceSeqTuple4 converts a [tuple.Tuple4[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]]
func SequenceSeqTuple5 ¶
func SequenceSeqTuple5[E, T1, T2, T3, T4, T5 any](t tuple.Tuple5[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5]]) IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]
SequenceSeqTuple5 converts a [tuple.Tuple5[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]]
func SequenceSeqTuple6 ¶
func SequenceSeqTuple6[E, T1, T2, T3, T4, T5, T6 any](t tuple.Tuple6[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5], IOEither[E, T6]]) IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]
SequenceSeqTuple6 converts a [tuple.Tuple6[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]]
func SequenceSeqTuple7 ¶
func SequenceSeqTuple7[E, T1, T2, T3, T4, T5, T6, T7 any](t tuple.Tuple7[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5], IOEither[E, T6], IOEither[E, T7]]) IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]
SequenceSeqTuple7 converts a [tuple.Tuple7[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]]
func SequenceSeqTuple8 ¶
func SequenceSeqTuple8[E, T1, T2, T3, T4, T5, T6, T7, T8 any](t tuple.Tuple8[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5], IOEither[E, T6], IOEither[E, T7], IOEither[E, T8]]) IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]
SequenceSeqTuple8 converts a [tuple.Tuple8[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]]
func SequenceSeqTuple9 ¶
func SequenceSeqTuple9[E, T1, T2, T3, T4, T5, T6, T7, T8, T9 any](t tuple.Tuple9[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5], IOEither[E, T6], IOEither[E, T7], IOEither[E, T8], IOEither[E, T9]]) IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]
SequenceSeqTuple9 converts a [tuple.Tuple9[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]]
func SequenceT1 ¶
SequenceT1 converts 1 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple1[T1]]]
func SequenceT10 ¶
func SequenceT10[E, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], t5 IOEither[E, T5], t6 IOEither[E, T6], t7 IOEither[E, T7], t8 IOEither[E, T8], t9 IOEither[E, T9], t10 IOEither[E, T10], ) IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]
SequenceT10 converts 10 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]]
func SequenceT2 ¶
func SequenceT2[E, T1, T2 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], ) IOEither[E, tuple.Tuple2[T1, T2]]
SequenceT2 converts 2 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple2[T1, T2]]]
func SequenceT3 ¶
func SequenceT3[E, T1, T2, T3 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], ) IOEither[E, tuple.Tuple3[T1, T2, T3]]
SequenceT3 converts 3 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple3[T1, T2, T3]]]
func SequenceT4 ¶
func SequenceT4[E, T1, T2, T3, T4 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], ) IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]
SequenceT4 converts 4 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]]
func SequenceT5 ¶
func SequenceT5[E, T1, T2, T3, T4, T5 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], t5 IOEither[E, T5], ) IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]
SequenceT5 converts 5 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]]
func SequenceT6 ¶
func SequenceT6[E, T1, T2, T3, T4, T5, T6 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], t5 IOEither[E, T5], t6 IOEither[E, T6], ) IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]
SequenceT6 converts 6 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]]
func SequenceT7 ¶
func SequenceT7[E, T1, T2, T3, T4, T5, T6, T7 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], t5 IOEither[E, T5], t6 IOEither[E, T6], t7 IOEither[E, T7], ) IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]
SequenceT7 converts 7 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]]
func SequenceT8 ¶
func SequenceT8[E, T1, T2, T3, T4, T5, T6, T7, T8 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], t5 IOEither[E, T5], t6 IOEither[E, T6], t7 IOEither[E, T7], t8 IOEither[E, T8], ) IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]
SequenceT8 converts 8 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]]
func SequenceT9 ¶
func SequenceT9[E, T1, T2, T3, T4, T5, T6, T7, T8, T9 any]( t1 IOEither[E, T1], t2 IOEither[E, T2], t3 IOEither[E, T3], t4 IOEither[E, T4], t5 IOEither[E, T5], t6 IOEither[E, T6], t7 IOEither[E, T7], t8 IOEither[E, T8], t9 IOEither[E, T9], ) IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]
SequenceT9 converts 9 [IOEither[E, T]] into a [IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]]
func SequenceTuple1 ¶
SequenceTuple1 converts a [tuple.Tuple1[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple1[T1]]]
func SequenceTuple10 ¶
func SequenceTuple10[E, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](t tuple.Tuple10[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5], IOEither[E, T6], IOEither[E, T7], IOEither[E, T8], IOEither[E, T9], IOEither[E, T10]]) IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]
SequenceTuple10 converts a [tuple.Tuple10[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]]
func SequenceTuple2 ¶
func SequenceTuple2[E, T1, T2 any](t tuple.Tuple2[IOEither[E, T1], IOEither[E, T2]]) IOEither[E, tuple.Tuple2[T1, T2]]
SequenceTuple2 converts a [tuple.Tuple2[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple2[T1, T2]]]
func SequenceTuple3 ¶
func SequenceTuple3[E, T1, T2, T3 any](t tuple.Tuple3[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3]]) IOEither[E, tuple.Tuple3[T1, T2, T3]]
SequenceTuple3 converts a [tuple.Tuple3[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple3[T1, T2, T3]]]
func SequenceTuple4 ¶
func SequenceTuple4[E, T1, T2, T3, T4 any](t tuple.Tuple4[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4]]) IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]
SequenceTuple4 converts a [tuple.Tuple4[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple4[T1, T2, T3, T4]]]
func SequenceTuple5 ¶
func SequenceTuple5[E, T1, T2, T3, T4, T5 any](t tuple.Tuple5[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5]]) IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]
SequenceTuple5 converts a [tuple.Tuple5[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple5[T1, T2, T3, T4, T5]]]
func SequenceTuple6 ¶
func SequenceTuple6[E, T1, T2, T3, T4, T5, T6 any](t tuple.Tuple6[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5], IOEither[E, T6]]) IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]
SequenceTuple6 converts a [tuple.Tuple6[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple6[T1, T2, T3, T4, T5, T6]]]
func SequenceTuple7 ¶
func SequenceTuple7[E, T1, T2, T3, T4, T5, T6, T7 any](t tuple.Tuple7[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5], IOEither[E, T6], IOEither[E, T7]]) IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]
SequenceTuple7 converts a [tuple.Tuple7[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple7[T1, T2, T3, T4, T5, T6, T7]]]
func SequenceTuple8 ¶
func SequenceTuple8[E, T1, T2, T3, T4, T5, T6, T7, T8 any](t tuple.Tuple8[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5], IOEither[E, T6], IOEither[E, T7], IOEither[E, T8]]) IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]
SequenceTuple8 converts a [tuple.Tuple8[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]]
func SequenceTuple9 ¶
func SequenceTuple9[E, T1, T2, T3, T4, T5, T6, T7, T8, T9 any](t tuple.Tuple9[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5], IOEither[E, T6], IOEither[E, T7], IOEither[E, T8], IOEither[E, T9]]) IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]
SequenceTuple9 converts a [tuple.Tuple9[IOEither[E, T]]] into a [IOEither[E, tuple.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]]
func Swap ¶
func Swap[E, A any](val IOEither[E, A]) IOEither[A, E]
Swap changes the order of type parameters
func TryCatchError ¶
type Kleisli ¶
func LogJSON ¶
LogJSON converts the argument to pretty printed JSON and then logs it via the format string Can be used with ChainFirst and Tap
func TailRec ¶
func TailRec[E, A, B any](f Kleisli[E, A, tailrec.Trampoline[A, B]]) Kleisli[E, A, B]
TailRec creates a tail-recursive computation in the IOEither monad. It enables writing recursive algorithms that don't overflow the call stack by using trampolining - a technique where recursive calls are converted into iterations.
The function takes a step function that returns a Trampoline:
- Bounce(A): Continue recursion with a new value of type A
- Land(B): Terminate recursion with a final result of type B
This is particularly useful for implementing recursive algorithms like:
- Iterative calculations (factorial, fibonacci, etc.)
- State machines with multiple steps
- Loops that may fail at any iteration
- Processing collections with early termination
The recursion is stack-safe because each step returns a value that indicates whether to continue (Bounce) or stop (Land), rather than making direct recursive calls.
Type Parameters:
- E: The error type that may occur during computation
- A: The intermediate type used during recursion (loop state)
- B: The final result type when recursion terminates
Parameters:
- f: A step function that takes the current state (A) and returns an IOEither containing either Bounce(A) to continue with a new state, or Land(B) to terminate with a final result
Returns:
- A Kleisli arrow (function from A to IOEither[E, B]) that executes the tail-recursive computation starting from the initial value
Example - Computing factorial in a stack-safe way:
type FactState struct {
n int
result int
}
factorial := TailRec(func(state FactState) IOEither[error, tailrec.Trampoline[FactState, int]] {
if state.n <= 1 {
// Terminate with final result
return Of[error](tailrec.Land[FactState](state.result))
}
// Continue with next iteration
return Of[error](tailrec.Bounce[int](FactState{
n: state.n - 1,
result: state.result * state.n,
}))
})
result := factorial(FactState{n: 5, result: 1})() // Right(120)
Example - Processing a list with potential errors:
type ProcessState struct {
items []string
sum int
}
processItems := TailRec(func(state ProcessState) IOEither[error, tailrec.Trampoline[ProcessState, int]] {
if len(state.items) == 0 {
return Of[error](tailrec.Land[ProcessState](state.sum))
}
val, err := strconv.Atoi(state.items[0])
if err != nil {
return Left[tailrec.Trampoline[ProcessState, int]](err)
}
return Of[error](tailrec.Bounce[int](ProcessState{
items: state.items[1:],
sum: state.sum + val,
}))
})
result := processItems(ProcessState{items: []string{"1", "2", "3"}, sum: 0})() // Right(6)
func TraverseArray ¶
func TraverseArray[E, A, B any](f Kleisli[E, A, B]) Kleisli[E, []A, []B]
TraverseArray transforms an array
func TraverseArrayPar ¶
func TraverseArrayPar[E, A, B any](f Kleisli[E, A, B]) Kleisli[E, []A, []B]
TraverseArrayPar transforms an array
func TraverseArraySeq ¶
func TraverseArraySeq[E, A, B any](f Kleisli[E, A, B]) Kleisli[E, []A, []B]
TraverseArraySeq transforms an array
func TraverseArrayWithIndex ¶
TraverseArrayWithIndex transforms an array
func TraverseArrayWithIndexPar ¶
TraverseArrayWithIndexPar transforms an array
func TraverseArrayWithIndexSeq ¶
TraverseArrayWithIndexSeq transforms an array
func TraverseRecord ¶
func TraverseRecord[K comparable, E, A, B any](f Kleisli[E, A, B]) Kleisli[E, map[K]A, map[K]B]
TraverseRecord transforms a record
func TraverseRecordPar ¶
func TraverseRecordPar[K comparable, E, A, B any](f Kleisli[E, A, B]) Kleisli[E, map[K]A, map[K]B]
TraverseRecordPar transforms a record
func TraverseRecordSeq ¶
func TraverseRecordSeq[K comparable, E, A, B any](f Kleisli[E, A, B]) Kleisli[E, map[K]A, map[K]B]
TraverseRecordSeq transforms a record
func TraverseRecordWithIndex ¶
func TraverseRecordWithIndex[K comparable, E, A, B any](f func(K, A) IOEither[E, B]) Kleisli[E, map[K]A, map[K]B]
TraverseRecordWithIndex transforms a record
func TraverseRecordWithIndexPar ¶
func TraverseRecordWithIndexPar[K comparable, E, A, B any](f func(K, A) IOEither[E, B]) Kleisli[E, map[K]A, map[K]B]
TraverseRecordWithIndexPar transforms a record
func TraverseRecordWithIndexSeq ¶
func TraverseRecordWithIndexSeq[K comparable, E, A, B any](f func(K, A) IOEither[E, B]) Kleisli[E, map[K]A, map[K]B]
TraverseRecordWithIndexSeq transforms a record
func WithResource ¶
func WithResource[A, E, R, ANY any](onCreate IOEither[E, R], onRelease Kleisli[E, R, ANY]) Kleisli[E, Kleisli[E, R, A], A]
WithResource constructs a function that creates a resource, then operates on it and then releases the resource
type Monoid ¶
func ApplicativeMonoid ¶
ApplicativeMonoid returns a Monoid that concatenates IOEither instances via their applicative
func ApplicativeMonoidPar ¶
ApplicativeMonoid returns a Monoid that concatenates IOEither instances via their applicative
type Operator ¶
func ApFirst ¶
func ApFirst[A, E, B any](second IOEither[E, B]) Operator[E, A, A]
ApFirst combines two effectful actions, keeping only the result of the first.
func ApPar ¶
func ApPar[B, E, A any](ma IOEither[E, A]) Operator[E, func(A) B, B]
ApPar applies function and value in parallel
func ApS ¶
func ApS[E, S1, S2, T any]( setter func(T) func(S1) S2, fa IOEither[E, T], ) Operator[E, S1, S2]
ApS attaches a value to a context [S1] to produce a context [S2] by considering the context and the value concurrently (using Applicative rather than Monad). This allows independent computations to be combined without one depending on the result of the other.
Unlike Bind, which sequences operations, ApS can be used when operations are independent and can conceptually run in parallel.
Example:
type State struct {
User User
Posts []Post
}
// These operations are independent and can be combined with ApS
getUser := ioeither.Right[error](User{ID: 1, Name: "Alice"})
getPosts := ioeither.Right[error]([]Post{{ID: 1, Title: "Hello"}})
result := F.Pipe2(
ioeither.Do[error](State{}),
ioeither.ApS(
func(user User) func(State) State {
return func(s State) State { s.User = user; return s }
},
getUser,
),
ioeither.ApS(
func(posts []Post) func(State) State {
return func(s State) State { s.Posts = posts; return s }
},
getPosts,
),
)
func ApSL ¶
ApSL attaches a value to a context using a lens-based setter. This is a convenience function that combines ApS with a lens, allowing you to use optics to update nested structures in a more composable way.
The lens parameter provides both the getter and setter for a field within the structure S. This eliminates the need to manually write setter functions.
Example:
type Config struct {
Host string
Port int
}
portLens := lens.MakeLens(
func(c Config) int { return c.Port },
func(c Config, p int) Config { c.Port = p; return c },
)
result := F.Pipe2(
ioeither.Of[error](Config{Host: "localhost"}),
ioeither.ApSL(portLens, ioeither.Of[error](8080)),
)
func ApSecond ¶
func ApSecond[A, E, B any](second IOEither[E, B]) Operator[E, A, B]
ApSecond combines two effectful actions, keeping only the result of the second.
func Bind ¶
func Bind[E, S1, S2, T any]( setter func(T) func(S1) S2, f Kleisli[E, S1, T], ) Operator[E, S1, S2]
Bind attaches the result of a computation to a context [S1] to produce a context [S2]. This enables sequential composition where each step can depend on the results of previous steps.
The setter function takes the result of the computation and returns a function that updates the context from S1 to S2.
Example:
type State struct {
User User
Posts []Post
}
result := F.Pipe2(
ioeither.Do[error](State{}),
ioeither.Bind(
func(user User) func(State) State {
return func(s State) State { s.User = user; return s }
},
func(s State) ioeither.IOEither[error, User] {
return ioeither.TryCatch(func() (User, error) {
return fetchUser()
})
},
),
ioeither.Bind(
func(posts []Post) func(State) State {
return func(s State) State { s.Posts = posts; return s }
},
func(s State) ioeither.IOEither[error, []Post] {
// This can access s.User from the previous step
return ioeither.TryCatch(func() ([]Post, error) {
return fetchPostsForUser(s.User.ID)
})
},
),
)
func BindL ¶
BindL attaches the result of a computation to a context using a lens-based setter. This is a convenience function that combines Bind with a lens, allowing you to use optics to update nested structures based on their current values.
The lens parameter provides both the getter and setter for a field within the structure S. The computation function f receives the current value of the focused field and returns an IOEither that produces the new value.
Example:
type Counter struct {
Value int
}
valueLens := lens.MakeLens(
func(c Counter) int { return c.Value },
func(c Counter, v int) Counter { c.Value = v; return c },
)
increment := func(v int) ioeither.IOEither[error, int] {
return ioeither.TryCatch(func() (int, error) {
if v >= 100 {
return 0, errors.New("overflow")
}
return v + 1, nil
})
}
result := F.Pipe1(
ioeither.Of[error](Counter{Value: 42}),
ioeither.BindL(valueLens, increment),
)
func BindTo ¶
func BindTo[E, S1, T any]( setter func(T) S1, ) Operator[E, T, S1]
BindTo initializes a new state [S1] from a value [T]
func ChainConsumer ¶
ChainConsumer converts a Consumer into an IOEither operator that executes the consumer as a side effect on successful (Right) values and returns an empty struct.
This function bridges the gap between pure consumers (functions that consume values without returning anything) and the IOEither monad. It takes a Consumer[A] and returns an Operator that:
- If the IOEither is Right, executes the consumer with the value as a side effect
- If the IOEither is Left, propagates the error without calling the consumer
- Returns IOEither[E, struct{}] to maintain the monadic chain
The consumer is only executed for successful (Right) values. Errors (Left values) are propagated unchanged. This is useful for operations like logging successful results, collecting metrics, or updating external state within an IOEither pipeline.
Type Parameters:
- E: The error type of the IOEither
- A: The type of value consumed by the consumer
Parameters:
- c: A Consumer[A] that performs side effects on values of type A
Returns:
- An Operator[E, A, struct{}] that executes the consumer on Right values and returns an empty struct
Example:
// Create a consumer that logs successful values
logger := func(x int) {
fmt.Printf("Success: %d\n", x)
}
// Convert it to an IOEither operator
logOp := ioeither.ChainConsumer[error](logger)
// Use it in an IOEither pipeline
result := F.Pipe2(
ioeither.Right[error](42),
logOp, // Logs "Success: 42"
ioeither.Map[error](func(struct{}) string { return "done" }),
)
result() // Returns Right("done") after logging
// Errors are propagated without calling the consumer
errorResult := F.Pipe2(
ioeither.Left[int](errors.New("failed")),
logOp, // Consumer NOT called
ioeither.Map[error](func(struct{}) string { return "done" }),
)
errorResult() // Returns Left(error) without logging
// Example with data collection
var successfulValues []int
collector := func(x int) {
successfulValues = append(successfulValues, x)
}
pipeline := F.Pipe2(
ioeither.Right[error](100),
ioeither.ChainConsumer[error](collector), // Collects the value
ioeither.Map[error](func(struct{}) int { return len(successfulValues) }),
)
count := pipeline() // Returns Right(1), successfulValues contains [100]
func ChainEitherK ¶
func ChainFirst ¶
func ChainFirst[E, A, B any](f Kleisli[E, A, B]) Operator[E, A, A]
func ChainFirstConsumer ¶
func ChainFirstEitherK ¶
func ChainFirstIOK ¶
ChainFirstIOK runs the IO monad returned by the function but returns the result of the original monad
func ChainFirstLeft ¶
func ChainFirstLeft[A, EA, EB, B any](f Kleisli[EB, EA, B]) Operator[EA, A, A]
ChainFirstLeft is the curried version of MonadChainFirstLeft. It returns a function that chains a computation on the left (error) side while always preserving the original error.
This is particularly useful for adding error handling side effects (like logging, metrics, or notifications) in a functional pipeline. The original error is always returned regardless of what f returns (Left or Right), ensuring the error path is preserved.
Parameters:
- f: A function that takes an error of type EA and returns an IOEither (typically for side effects)
Returns:
- An Operator that performs the side effect but always returns the original error if input was Left
Example:
// Create a reusable error logger
logError := ChainFirstLeft(func(err string) IOEither[any, int] {
return FromIO[any](func() int {
log.Printf("Error: %s", err)
return 0
})
})
result := F.Pipe1(
Left[int]("validation failed"),
logError, // logs the error
)
// result is always Left("validation failed"), even though f returns Right
func ChainLazyK ¶
func ChainTo ¶
func ChainTo[A, E, B any](fb IOEither[E, B]) Operator[E, A, B]
ChainTo composes to the second IOEither monad ignoring the return value of the first
func Let ¶
func Let[E, S1, S2, T any]( setter func(T) func(S1) S2, f func(S1) T, ) Operator[E, S1, S2]
Let attaches the result of a computation to a context [S1] to produce a context [S2]
func LetL ¶
LetL attaches the result of a pure computation to a context using a lens-based setter. This is a convenience function that combines Let with a lens, allowing you to use optics to update nested structures with pure transformations.
The lens parameter provides both the getter and setter for a field within the structure S. The transformation function f receives the current value of the focused field and returns the new value directly (not wrapped in IOEither).
Example:
type Counter struct {
Value int
}
valueLens := lens.MakeLens(
func(c Counter) int { return c.Value },
func(c Counter, v int) Counter { c.Value = v; return c },
)
double := func(v int) int { return v * 2 }
result := F.Pipe1(
ioeither.Of[error](Counter{Value: 21}),
ioeither.LetL(valueLens, double),
)
func LetTo ¶
func LetTo[E, S1, S2, T any]( setter func(T) func(S1) S2, b T, ) Operator[E, S1, S2]
LetTo attaches the a value to a context [S1] to produce a context [S2]
func LetToL ¶
LetToL attaches a constant value to a context using a lens-based setter. This is a convenience function that combines LetTo with a lens, allowing you to use optics to set nested fields to specific values.
The lens parameter provides the setter for a field within the structure S. Unlike LetL which transforms the current value, LetToL simply replaces it with the provided constant value b.
Example:
type Config struct {
Debug bool
Timeout int
}
debugLens := lens.MakeLens(
func(c Config) bool { return c.Debug },
func(c Config, d bool) Config { c.Debug = d; return c },
)
result := F.Pipe1(
ioeither.Of[error](Config{Debug: true, Timeout: 30}),
ioeither.LetToL(debugLens, false),
)
func LogEntryExit ¶
LogEntryExit creates an operator that logs the entry and exit of an IOEither computation with timing information.
This function wraps an IOEither computation with automatic logging that tracks:
- Entry: Logs when the computation starts with "[entering] <name>"
- Exit: Logs when the computation completes successfully with "[exiting ] <name> [duration]"
- Error: Logs when the computation fails with "[throwing] <name> [duration]: <error>"
The duration is measured in seconds with one decimal place precision (e.g., "2.5s"). This is particularly useful for debugging, performance monitoring, and understanding the execution flow of complex IOEither chains.
Type Parameters:
- E: The error type (Left value) of the IOEither
- A: The success type (Right value) of the IOEither
Parameters:
- name: A descriptive name for the computation, used in log messages to identify the operation
Returns:
- An Operator that wraps the IOEither computation with entry/exit logging
The function uses the bracket pattern to ensure that:
- Entry is logged before the computation starts
- Exit/error is logged after the computation completes, regardless of success or failure
- Timing is accurate, measuring from entry to exit
- The original result is preserved and returned unchanged
Log Format:
- Entry: "[entering] <name>"
- Success: "[exiting ] <name> [<duration>s]"
- Error: "[throwing] <name> [<duration>s]: <error>"
Example with successful computation:
fetchUser := func(id int) IOEither[error, User] {
return TryCatch(func() (User, error) {
// Simulate database query
time.Sleep(100 * time.Millisecond)
return User{ID: id, Name: "Alice"}, nil
})
}
// Wrap with logging
loggedFetch := LogEntryExit[error, User]("fetchUser")(fetchUser(123))
// Execute
result := loggedFetch()
// Logs:
// [entering] fetchUser
// [exiting ] fetchUser [0.1s]
Example with error:
failingOp := func() IOEither[error, string] {
return TryCatch(func() (string, error) {
time.Sleep(50 * time.Millisecond)
return "", errors.New("connection timeout")
})
}
logged := LogEntryExit[error, string]("failingOp")(failingOp())
result := logged()
// Logs:
// [entering] failingOp
// [throwing] failingOp [0.1s]: connection timeout
Example with chained operations:
pipeline := F.Pipe3(
fetchUser(123),
LogEntryExit[error, User]("fetchUser"),
Chain(func(user User) IOEither[error, []Order] {
return fetchOrders(user.ID)
}),
LogEntryExit[error, []Order]("fetchOrders"),
)
// Logs each step with timing:
// [entering] fetchUser
// [exiting ] fetchUser [0.1s]
// [entering] fetchOrders
// [exiting ] fetchOrders [0.2s]
Example for performance monitoring:
slowQuery := func() IOEither[error, []Record] {
return TryCatch(func() ([]Record, error) {
// Simulate slow database query
time.Sleep(2 * time.Second)
return []Record{{ID: 1}}, nil
})
}
monitored := LogEntryExit[error, []Record]("slowQuery")(slowQuery())
result := monitored()
// Logs:
// [entering] slowQuery
// [exiting ] slowQuery [2.0s]
// Helps identify performance bottlenecks
Example with custom error types:
type AppError struct {
Code int
Message string
}
func (e AppError) Error() string {
return fmt.Sprintf("Error %d: %s", e.Code, e.Message)
}
operation := func() IOEither[AppError, Data] {
return Left[Data](AppError{Code: 404, Message: "Not Found"})
}
logged := LogEntryExit[AppError, Data]("operation")(operation())
result := logged()
// Logs:
// [entering] operation
// [throwing] operation [0.0s]: Error 404: Not Found
Use Cases:
- Debugging: Track execution flow through complex IOEither chains
- Performance monitoring: Identify slow operations with timing information
- Production logging: Monitor critical operations in production systems
- Testing: Verify that operations are executed in the expected order
- Troubleshooting: Quickly identify where errors occur in a pipeline
Note: This function uses Go's standard log package. For production systems, consider using a structured logging library and adapting this pattern to support different log levels and structured fields.
func LogEntryExitF ¶
func LogEntryExitF[E, A, STARTTOKEN, ANY any]( onEntry IO[STARTTOKEN], onExit io.Kleisli[pair.Pair[STARTTOKEN, Either[E, A]], ANY], ) Operator[E, A, A]
LogEntryExitF creates a customizable operator that wraps an IOEither computation with entry/exit callbacks.
This is a more flexible version of LogEntryExit that allows you to provide custom callbacks for entry and exit events. The onEntry callback is executed before the computation starts and can return a "start token" (such as a timestamp, trace ID, or any context data). This token is then passed to the onExit callback along with the computation result, enabling correlation between entry and exit events.
The function uses the bracket pattern to ensure that:
- The onEntry callback is executed before the computation starts
- The onExit callback is executed after the computation completes (success or failure)
- The start token from onEntry is available in onExit for correlation
- The original result is preserved and returned unchanged
- Cleanup happens even if the computation fails
Type Parameters:
- E: The error type (Left value) of the IOEither
- A: The success type (Right value) of the IOEither
- STARTTOKEN: The type of the token returned by onEntry (e.g., time.Time, string, trace.Span)
- ANY: The return type of the onExit callback (typically any or a specific type)
Parameters:
- onEntry: An IO action executed when the computation starts. Returns a STARTTOKEN that will be passed to onExit. Use this for logging entry, starting timers, creating trace spans, etc.
- onExit: A Kleisli function that receives a Pair containing:
- Head: STARTTOKEN - the token returned by onEntry
- Tail: Either[E, A] - the result of the computation (Left for error, Right for success) Use this for logging exit, recording metrics, closing spans, or cleanup logic.
Returns:
- An Operator that wraps the IOEither computation with the custom entry/exit callbacks
Example with timing (as used by LogEntryExit):
logOp := LogEntryExitF[error, User, time.Time, any](
func() time.Time {
log.Printf("[entering] fetchUser")
return time.Now() // Start token is the start time
},
func(res pair.Pair[time.Time, Either[error, User]]) IO[any] {
startTime := pair.Head(res)
result := pair.Tail(res)
duration := time.Since(startTime).Seconds()
return func() any {
if either.IsLeft(result) {
log.Printf("[throwing] fetchUser [%.1fs]: %v", duration, either.GetLeft(result))
} else {
log.Printf("[exiting] fetchUser [%.1fs]", duration)
}
return nil
}
},
)
wrapped := logOp(fetchUser(123))
Example with distributed tracing:
import "go.opentelemetry.io/otel/trace"
tracer := otel.Tracer("my-service")
traceOp := LogEntryExitF[error, Data, trace.Span, any](
func() trace.Span {
_, span := tracer.Start(ctx, "fetchData")
return span // Start token is the span
},
func(res pair.Pair[trace.Span, Either[error, Data]]) IO[any] {
span := pair.Head(res) // Get the span from entry
result := pair.Tail(res)
return func() any {
if either.IsLeft(result) {
span.RecordError(either.GetLeft(result))
span.SetStatus(codes.Error, "operation failed")
} else {
span.SetStatus(codes.Ok, "operation succeeded")
}
span.End() // Close the span
return nil
}
},
)
Example with correlation ID:
type RequestContext struct {
CorrelationID string
StartTime time.Time
}
correlationOp := LogEntryExitF[error, Response, RequestContext, any](
func() RequestContext {
ctx := RequestContext{
CorrelationID: uuid.New().String(),
StartTime: time.Now(),
}
log.Printf("[%s] Request started", ctx.CorrelationID)
return ctx
},
func(res pair.Pair[RequestContext, Either[error, Response]]) IO[any] {
ctx := pair.Head(res)
result := pair.Tail(res)
duration := time.Since(ctx.StartTime)
return func() any {
if either.IsLeft(result) {
log.Printf("[%s] Request failed after %v: %v",
ctx.CorrelationID, duration, either.GetLeft(result))
} else {
log.Printf("[%s] Request completed after %v",
ctx.CorrelationID, duration)
}
return nil
}
},
)
Example with metrics collection:
import "github.com/prometheus/client_golang/prometheus"
type MetricsToken struct {
StartTime time.Time
OpName string
}
metricsOp := LogEntryExitF[error, Result, MetricsToken, any](
func() MetricsToken {
token := MetricsToken{
StartTime: time.Now(),
OpName: "api_call",
}
requestCount.WithLabelValues(token.OpName, "started").Inc()
return token
},
func(res pair.Pair[MetricsToken, Either[error, Result]]) IO[any] {
token := pair.Head(res)
result := pair.Tail(res)
duration := time.Since(token.StartTime).Seconds()
return func() any {
if either.IsLeft(result) {
requestCount.WithLabelValues(token.OpName, "error").Inc()
requestDuration.WithLabelValues(token.OpName, "error").Observe(duration)
} else {
requestCount.WithLabelValues(token.OpName, "success").Inc()
requestDuration.WithLabelValues(token.OpName, "success").Observe(duration)
}
return nil
}
},
)
Use Cases:
- Structured logging: Integration with zap, logrus, or other structured loggers
- Distributed tracing: OpenTelemetry, Jaeger, Zipkin integration with span management
- Metrics collection: Recording operation durations, success/failure rates with Prometheus
- Request correlation: Tracking requests across service boundaries with correlation IDs
- Custom monitoring: Application-specific monitoring and alerting
- Audit logging: Recording detailed operation information for compliance
Note: LogEntryExit is implemented using LogEntryExitF with time.Time as the start token. Use LogEntryExitF when you need more control over the entry/exit behavior or need to pass custom context between entry and exit callbacks.