ioeither

package
v1.0.143 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 15 Imported by: 11

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func After added in v1.0.97

func After[E, A any](timestamp time.Time) func(IOEither[E, A]) IOEither[E, A]

After creates an operation that passes after the given time.Time

func Alt added in v1.0.31

func Alt[E, A any](second L.Lazy[IOEither[E, A]]) func(IOEither[E, A]) IOEither[E, A]

Alt identifies an associative operation on a type constructor

func AltSemigroup added in v1.0.31

func AltSemigroup[E, A any]() S.Semigroup[IOEither[E, A]]

AltSemigroup is a [Semigroup] that tries the first item and then the second one using an alternative

func Ap

func Ap[B, E, A any](ma IOEither[E, A]) func(IOEither[E, func(A) B]) IOEither[E, B]

Ap is an alias of ApPar

func ApFirst

func ApFirst[A, E, B any](second IOEither[E, B]) func(IOEither[E, A]) IOEither[E, A]

ApFirst combines two effectful actions, keeping only the result of the first.

func ApPar added in v1.0.55

func ApPar[B, E, A any](ma IOEither[E, A]) func(IOEither[E, func(A) B]) IOEither[E, B]

ApPar applies function and value in parallel

func ApS added in v1.0.20

func ApS[E, S1, S2, T any](
	setter func(T) func(S1) S2,
	fa IOEither[E, T],
) func(IOEither[E, S1]) IOEither[E, S2]

ApS attaches a value to a context [S1] to produce a context [S2] by considering the context and the value concurrently

func ApSecond

func ApSecond[A, E, B any](second IOEither[E, B]) func(IOEither[E, A]) IOEither[E, B]

ApSecond combines two effectful actions, keeping only the result of the second.

func ApSeq added in v1.0.55

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 ApplicativeMonoid added in v1.0.31

func ApplicativeMonoid[E, A any](
	m M.Monoid[A],
) M.Monoid[IOEither[E, A]]

ApplicativeMonoid returns a [Monoid] that concatenates IOEither instances via their applicative

func ApplicativeMonoidPar added in v1.0.31

func ApplicativeMonoidPar[E, A any](
	m M.Monoid[A],
) M.Monoid[IOEither[E, A]]

ApplicativeMonoid returns a [Monoid] that concatenates IOEither instances via their applicative

func ApplicativeMonoidSeq added in v1.0.31

func ApplicativeMonoidSeq[E, A any](
	m M.Monoid[A],
) M.Monoid[IOEither[E, A]]

ApplicativeMonoid returns a [Monoid] that concatenates IOEither instances via their applicative

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 Bind added in v1.0.20

func Bind[E, S1, S2, T any](
	setter func(T) func(S1) S2,
	f func(S1) IOEither[E, T],
) func(IOEither[E, S1]) IOEither[E, S2]

Bind attaches the result of a computation to a context [S1] to produce a context [S2]

func BindTo added in v1.0.20

func BindTo[E, S1, T any](
	setter func(T) S1,
) func(IOEither[E, T]) IOEither[E, S1]

BindTo initializes a new state [S1] from a value [T]

func Chain

func Chain[E, A, B any](f func(A) IOEither[E, B]) func(IOEither[E, A]) IOEither[E, B]

func ChainEitherK

func ChainEitherK[E, A, B any](f func(A) ET.Either[E, B]) func(IOEither[E, A]) IOEither[E, B]

func ChainFirst

func ChainFirst[E, A, B any](f func(A) IOEither[E, B]) func(IOEither[E, A]) IOEither[E, A]

ChainFirst runs the IOEither monad returned by the function but returns the result of the original monad

func ChainFirstEitherK added in v1.0.58

func ChainFirstEitherK[A, E, B any](f func(A) ET.Either[E, B]) func(ma IOEither[E, A]) IOEither[E, A]

func ChainFirstIOK

func ChainFirstIOK[E, A, B any](f func(A) I.IO[B]) func(IOEither[E, A]) IOEither[E, A]

ChainFirstIOK runs the [IO] monad returned by the function but returns the result of the original monad

func ChainIOK

func ChainIOK[E, A, B any](f func(A) I.IO[B]) func(IOEither[E, A]) IOEither[E, B]

func ChainLazyK added in v1.0.33

func ChainLazyK[E, A, B any](f func(A) L.Lazy[B]) func(IOEither[E, A]) IOEither[E, B]

func ChainOptionK

func ChainOptionK[A, B, E any](onNone func() E) func(func(A) O.Option[B]) func(IOEither[E, A]) IOEither[E, B]

func ChainTo

func ChainTo[A, E, B any](fb IOEither[E, B]) func(IOEither[E, A]) IOEither[E, B]

ChainTo composes to the second IOEither monad ignoring the return value of the first

func Delay added in v1.0.97

func Delay[E, A any](delay time.Duration) func(IOEither[E, A]) IOEither[E, A]

Delay creates an operation that passes in the value after some delay

func Eitherize0

func Eitherize0[F ~func() (R, error), R any](f F) func() IOEither[error, R]

Eitherize0 converts a function with 1 parameters returning a tuple into a function with 0 parameters returning a [IOEither[error, R]]

func Eitherize1

func Eitherize1[F ~func(T1) (R, error), T1, R any](f F) func(T1) IOEither[error, R]

Eitherize1 converts a function with 2 parameters returning a tuple into a function with 1 parameters returning a [IOEither[error, R]]

func Eitherize10 added in v1.0.7

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

func Eitherize2[F ~func(T1, T2) (R, error), T1, T2, R any](f F) func(T1, T2) IOEither[error, R]

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 added in v1.0.7

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 added in v1.0.7

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 added in v1.0.7

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 added in v1.0.7

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 added in v1.0.7

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 Eq

func Eq[E, A any](eq EQ.Eq[ET.Either[E, A]]) EQ.Eq[IOEither[E, A]]

Eq implements the equals predicate for values contained in the IOEither monad

func Flap added in v1.0.46

func Flap[E, B, A any](a A) func(IOEither[E, func(A) B]) IOEither[E, B]

func Fold

func Fold[E, A, B any](onLeft func(E) I.IO[B], onRight func(A) I.IO[B]) func(IOEither[E, A]) I.IO[B]

Fold converts an IOEither into an IO

func FromIOOption added in v1.0.59

func FromIOOption[A, E any](onNone func() E) func(o IOO.IOOption[A]) IOEither[E, A]

func FromOption

func FromOption[A, E any](onNone func() E) func(o O.Option[A]) IOEither[E, A]

func FromStrictEquals

func FromStrictEquals[E, A comparable]() EQ.Eq[IOEither[E, A]]

FromStrictEquals constructs an [EQ.Eq] from the canonical comparison function

func GetOrElse

func GetOrElse[E, A any](onLeft func(E) I.IO[A]) func(IOEither[E, A]) I.IO[A]

GetOrElse extracts the value or maps the error

func Let added in v1.0.20

func Let[E, S1, S2, T any](
	setter func(T) func(S1) S2,
	f func(S1) T,
) func(IOEither[E, S1]) IOEither[E, S2]

Let attaches the result of a computation to a context [S1] to produce a context [S2]

func LetTo added in v1.0.107

func LetTo[E, S1, S2, T any](
	setter func(T) func(S1) S2,
	b T,
) func(IOEither[E, S1]) IOEither[E, S2]

LetTo attaches the a value to a context [S1] to produce a context [S2]

func LogJSON added in v1.0.118

func LogJSON[A any](prefix string) func(A) IOEither[error, any]

LogJSON converts the argument to pretty printed JSON and then logs it via the format string Can be used with ChainFirst

func LogJson deprecated added in v1.0.99

func LogJson[A any](prefix string) func(A) IOEither[error, any]

LogJson converts the argument to pretty printed JSON and then logs it via the format string Can be used with ChainFirst

Deprecated: use LogJSON instead

func Map

func Map[E, A, B any](f func(A) B) func(IOEither[E, A]) IOEither[E, B]

func MapLeft

func MapLeft[A, E1, E2 any](f func(E1) E2) func(IOEither[E1, A]) IOEither[E2, A]

func MapTo

func MapTo[E, A, B any](b B) func(IOEither[E, A]) IOEither[E, B]

func Monad added in v1.0.133

func Monad[E, A, B any]() monad.Monad[A, B, IOEither[E, A], IOEither[E, B], IOEither[E, func(A) B]]

Monad returns the monadic operations for IOEither

func Pointed added in v1.0.133

func Pointed[E, A any]() pointed.Pointed[A, IOEither[E, A]]

Pointed returns the pointed operations for IOEither

func ToIOOption added in v1.0.59

func ToIOOption[E, A any](ioe IOEither[E, A]) IOO.IOOption[A]

ToIOOption converts an IOEither to an [IOO.IOOption]

func TraverseArray

func TraverseArray[E, A, B any](f func(A) IOEither[E, B]) func([]A) IOEither[E, []B]

TraverseArray transforms an array

func TraverseArrayPar added in v1.0.61

func TraverseArrayPar[E, A, B any](f func(A) IOEither[E, B]) func([]A) IOEither[E, []B]

TraverseArrayPar transforms an array

func TraverseArraySeq added in v1.0.61

func TraverseArraySeq[E, A, B any](f func(A) IOEither[E, B]) func([]A) IOEither[E, []B]

TraverseArraySeq transforms an array

func TraverseArrayWithIndex added in v1.0.29

func TraverseArrayWithIndex[E, A, B any](f func(int, A) IOEither[E, B]) func([]A) IOEither[E, []B]

TraverseArrayWithIndex transforms an array

func TraverseArrayWithIndexPar added in v1.0.61

func TraverseArrayWithIndexPar[E, A, B any](f func(int, A) IOEither[E, B]) func([]A) IOEither[E, []B]

TraverseArrayWithIndexPar transforms an array

func TraverseArrayWithIndexSeq added in v1.0.61

func TraverseArrayWithIndexSeq[E, A, B any](f func(int, A) IOEither[E, B]) func([]A) IOEither[E, []B]

TraverseArrayWithIndexSeq transforms an array

func TraverseRecord

func TraverseRecord[K comparable, E, A, B any](f func(A) IOEither[E, B]) func(map[K]A) IOEither[E, map[K]B]

TraverseRecord transforms a record

func TraverseRecordPar added in v1.0.61

func TraverseRecordPar[K comparable, E, A, B any](f func(A) IOEither[E, B]) func(map[K]A) IOEither[E, map[K]B]

TraverseRecordPar transforms a record

func TraverseRecordSeq added in v1.0.61

func TraverseRecordSeq[K comparable, E, A, B any](f func(A) IOEither[E, B]) func(map[K]A) IOEither[E, map[K]B]

TraverseRecordSeq transforms a record

func TraverseRecordWithIndex added in v1.0.29

func TraverseRecordWithIndex[K comparable, E, A, B any](f func(K, A) IOEither[E, B]) func(map[K]A) IOEither[E, map[K]B]

TraverseRecordWithIndex transforms a record

func TraverseRecordWithIndexPar added in v1.0.61

func TraverseRecordWithIndexPar[K comparable, E, A, B any](f func(K, A) IOEither[E, B]) func(map[K]A) IOEither[E, map[K]B]

TraverseRecordWithIndexPar transforms a record

func TraverseRecordWithIndexSeq added in v1.0.61

func TraverseRecordWithIndexSeq[K comparable, E, A, B any](f func(K, A) IOEither[E, B]) func(map[K]A) IOEither[E, map[K]B]

TraverseRecordWithIndexSeq transforms a record

func TraverseTuple1 added in v1.0.7

func TraverseTuple1[F1 ~func(A1) IOEither[E, T1], E, A1, T1 any](f1 F1) func(T.Tuple1[A1]) IOEither[E, T.Tuple1[T1]]

TraverseTuple1 converts a [T.Tuple1[IOEither[E, T]]] into a [IOEither[E, T.Tuple1[T1]]]

func TraverseTuple10 added in v1.0.7

func TraverseTuple10[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], E, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10) func(T.Tuple10[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10]) IOEither[E, T.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]

TraverseTuple10 converts a [T.Tuple10[IOEither[E, T]]] into a [IOEither[E, T.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]]

func TraverseTuple2 added in v1.0.7

func TraverseTuple2[F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], E, A1, A2, T1, T2 any](f1 F1, f2 F2) func(T.Tuple2[A1, A2]) IOEither[E, T.Tuple2[T1, T2]]

TraverseTuple2 converts a [T.Tuple2[IOEither[E, T]]] into a [IOEither[E, T.Tuple2[T1, T2]]]

func TraverseTuple3 added in v1.0.7

func TraverseTuple3[F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], E, A1, A2, A3, T1, T2, T3 any](f1 F1, f2 F2, f3 F3) func(T.Tuple3[A1, A2, A3]) IOEither[E, T.Tuple3[T1, T2, T3]]

TraverseTuple3 converts a [T.Tuple3[IOEither[E, T]]] into a [IOEither[E, T.Tuple3[T1, T2, T3]]]

func TraverseTuple4 added in v1.0.7

func TraverseTuple4[F1 ~func(A1) IOEither[E, T1], F2 ~func(A2) IOEither[E, T2], F3 ~func(A3) IOEither[E, T3], F4 ~func(A4) IOEither[E, T4], E, A1, A2, A3, A4, T1, T2, T3, T4 any](f1 F1, f2 F2, f3 F3, f4 F4) func(T.Tuple4[A1, A2, A3, A4]) IOEither[E, T.Tuple4[T1, T2, T3, T4]]

TraverseTuple4 converts a [T.Tuple4[IOEither[E, T]]] into a [IOEither[E, T.Tuple4[T1, T2, T3, T4]]]

func TraverseTuple5 added in v1.0.7

func TraverseTuple5[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], E, A1, A2, A3, A4, A5, T1, T2, T3, T4, T5 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5) func(T.Tuple5[A1, A2, A3, A4, A5]) IOEither[E, T.Tuple5[T1, T2, T3, T4, T5]]

TraverseTuple5 converts a [T.Tuple5[IOEither[E, T]]] into a [IOEither[E, T.Tuple5[T1, T2, T3, T4, T5]]]

func TraverseTuple6 added in v1.0.7

func TraverseTuple6[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], E, A1, A2, A3, A4, A5, A6, T1, T2, T3, T4, T5, T6 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6) func(T.Tuple6[A1, A2, A3, A4, A5, A6]) IOEither[E, T.Tuple6[T1, T2, T3, T4, T5, T6]]

TraverseTuple6 converts a [T.Tuple6[IOEither[E, T]]] into a [IOEither[E, T.Tuple6[T1, T2, T3, T4, T5, T6]]]

func TraverseTuple7 added in v1.0.7

func TraverseTuple7[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], E, A1, A2, A3, A4, A5, A6, A7, T1, T2, T3, T4, T5, T6, T7 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7) func(T.Tuple7[A1, A2, A3, A4, A5, A6, A7]) IOEither[E, T.Tuple7[T1, T2, T3, T4, T5, T6, T7]]

TraverseTuple7 converts a [T.Tuple7[IOEither[E, T]]] into a [IOEither[E, T.Tuple7[T1, T2, T3, T4, T5, T6, T7]]]

func TraverseTuple8 added in v1.0.7

func TraverseTuple8[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], E, A1, A2, A3, A4, A5, A6, A7, A8, T1, T2, T3, T4, T5, T6, T7, T8 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8) func(T.Tuple8[A1, A2, A3, A4, A5, A6, A7, A8]) IOEither[E, T.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]

TraverseTuple8 converts a [T.Tuple8[IOEither[E, T]]] into a [IOEither[E, T.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]]

func TraverseTuple9 added in v1.0.7

func TraverseTuple9[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], E, A1, A2, A3, A4, A5, A6, A7, A8, A9, T1, T2, T3, T4, T5, T6, T7, T8, T9 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9) func(T.Tuple9[A1, A2, A3, A4, A5, A6, A7, A8, A9]) IOEither[E, T.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]

TraverseTuple9 converts a [T.Tuple9[IOEither[E, T]]] into a [IOEither[E, T.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]]

func Uneitherize0 added in v1.0.7

func Uneitherize0[F ~func() IOEither[error, R], R any](f F) func() (R, error)

Uneitherize0 converts a function with 1 parameters returning a tuple into a function with 0 parameters returning a [IOEither[error, R]]

func Uneitherize1 added in v1.0.7

func Uneitherize1[F ~func(T1) IOEither[error, R], T1, R any](f F) func(T1) (R, error)

Uneitherize1 converts a function with 2 parameters returning a tuple into a function with 1 parameters returning a [IOEither[error, R]]

func Uneitherize10 added in v1.0.7

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 added in v1.0.7

func Uneitherize2[F ~func(T1, T2) IOEither[error, R], T1, T2, R any](f F) func(T1, T2) (R, error)

Uneitherize2 converts a function with 3 parameters returning a tuple into a function with 2 parameters returning a [IOEither[error, R]]

func Uneitherize3 added in v1.0.7

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 added in v1.0.7

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 added in v1.0.7

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 added in v1.0.7

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 added in v1.0.7

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 added in v1.0.7

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 added in v1.0.7

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]]

func WithLock added in v1.0.50

func WithLock[E, A any](lock IO.IO[context.CancelFunc]) func(fa IOEither[E, A]) IOEither[E, A]

WithLock executes the provided IO operation in the scope of a lock

func WithResource

func WithResource[A, E, R, ANY any](onCreate IOEither[E, R], onRelease func(R) IOEither[E, ANY]) func(func(R) IOEither[E, A]) IOEither[E, A]

WithResource constructs a function that creates a resource, then operates on it and then releases the resource

Types

type IOEither

type IOEither[E, A any] I.IO[ET.Either[E, A]]

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.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 func(A) IOEither[E, B],
	release func(A, ET.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 Defer

func Defer[E, A any](gen L.Lazy[IOEither[E, A]]) IOEither[E, A]

Defer creates an IO by creating a brand new IO via a generator function, each time

func Do added in v1.0.107

func Do[E, S any](
	empty S,
) IOEither[E, S]

Bind creates an empty context of type [S] to be used with the Bind operation

func Flatten

func Flatten[E, A any](mma IOEither[E, IOEither[E, A]]) IOEither[E, A]

func FromEither

func FromEither[E, A any](e ET.Either[E, A]) IOEither[E, A]

func FromIO

func FromIO[E, A any](mr I.IO[A]) IOEither[E, A]

FromIO creates an IOEither from an [IO] instance, invoking [IO] for each invocation of IOEither

func FromImpure

func FromImpure[E any](f func()) IOEither[E, any]

FromImpure converts a side effect without a return value into a side effect that returns any

func FromLazy added in v1.0.33

func FromLazy[E, A any](mr L.Lazy[A]) IOEither[E, A]

FromLazy creates an IOEither from a [Lazy] instance, invoking [Lazy] for each invocation of IOEither

func Left

func Left[A, E any](l E) IOEither[E, A]

func LeftIO

func LeftIO[A, E any](ml I.IO[E]) IOEither[E, A]

func MakeIO

func MakeIO[E, A any](f IOEither[E, A]) IOEither[E, A]

func Memoize

func Memoize[E, A any](ma IOEither[E, A]) IOEither[E, A]

func MonadAlt added in v1.0.31

func MonadAlt[E, A any](first IOEither[E, A], second L.Lazy[IOEither[E, A]]) IOEither[E, A]

MonadAlt identifies an associative operation on a type constructor

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 added in v1.0.55

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 added in v1.0.55

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 func(A) IOEither[E, B]) IOEither[E, B]

func MonadChainEitherK

func MonadChainEitherK[E, A, B any](ma IOEither[E, A], f func(A) ET.Either[E, B]) IOEither[E, B]

func MonadChainFirst

func MonadChainFirst[E, A, B any](ma IOEither[E, A], f func(A) IOEither[E, B]) IOEither[E, A]

MonadChainFirst runs the IOEither monad returned by the function but returns the result of the original monad

func MonadChainFirstEitherK added in v1.0.58

func MonadChainFirstEitherK[A, E, B any](ma IOEither[E, A], f func(A) ET.Either[E, B]) IOEither[E, A]

func MonadChainFirstIOK

func MonadChainFirstIOK[E, A, B any](ma IOEither[E, A], f func(A) I.IO[B]) IOEither[E, A]

MonadChainFirstIOK runs [IO] the monad returned by the function but returns the result of the original monad

func MonadChainIOK

func MonadChainIOK[E, A, B any](ma IOEither[E, A], f func(A) I.IO[B]) IOEither[E, B]

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 MonadFlap added in v1.0.46

func MonadFlap[E, B, A any](fab IOEither[E, func(A) B], a A) IOEither[E, B]

func MonadMap

func MonadMap[E, A, B any](fa IOEither[E, A], f func(A) B) IOEither[E, B]

func MonadMapLeft

func MonadMapLeft[E1, E2, A 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 MonadOf

func MonadOf[E, A any](r A) IOEither[E, A]

func Of

func Of[E, A any](r A) IOEither[E, A]

func Retrying

func Retrying[E, A any](
	policy R.RetryPolicy,
	action func(R.RetryStatus) IOEither[E, A],
	check func(ET.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 Right[E, A any](r A) IOEither[E, A]

func RightIO

func RightIO[E, A any](mr I.IO[A]) IOEither[E, A]

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 added in v1.0.61

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 added in v1.0.61

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 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 added in v1.0.61

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 added in v1.0.61

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 SequenceT1

func SequenceT1[E, T1 any](
	t1 IOEither[E, T1],
) IOEither[E, T.Tuple1[T1]]

SequenceT1 converts 1 [IOEither[E, T]] into a [IOEither[E, T.Tuple1[T1]]]

func SequenceT10 added in v1.0.7

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, T.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]

SequenceT10 converts 10 [IOEither[E, T]] into a [IOEither[E, T.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, T.Tuple2[T1, T2]]

SequenceT2 converts 2 [IOEither[E, T]] into a [IOEither[E, T.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, T.Tuple3[T1, T2, T3]]

SequenceT3 converts 3 [IOEither[E, T]] into a [IOEither[E, T.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, T.Tuple4[T1, T2, T3, T4]]

SequenceT4 converts 4 [IOEither[E, T]] into a [IOEither[E, T.Tuple4[T1, T2, T3, T4]]]

func SequenceT5 added in v1.0.7

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, T.Tuple5[T1, T2, T3, T4, T5]]

SequenceT5 converts 5 [IOEither[E, T]] into a [IOEither[E, T.Tuple5[T1, T2, T3, T4, T5]]]

func SequenceT6 added in v1.0.7

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, T.Tuple6[T1, T2, T3, T4, T5, T6]]

SequenceT6 converts 6 [IOEither[E, T]] into a [IOEither[E, T.Tuple6[T1, T2, T3, T4, T5, T6]]]

func SequenceT7 added in v1.0.7

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, T.Tuple7[T1, T2, T3, T4, T5, T6, T7]]

SequenceT7 converts 7 [IOEither[E, T]] into a [IOEither[E, T.Tuple7[T1, T2, T3, T4, T5, T6, T7]]]

func SequenceT8 added in v1.0.7

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, T.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]

SequenceT8 converts 8 [IOEither[E, T]] into a [IOEither[E, T.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]]

func SequenceT9 added in v1.0.7

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, T.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]

SequenceT9 converts 9 [IOEither[E, T]] into a [IOEither[E, T.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]]

func SequenceTuple1 added in v1.0.7

func SequenceTuple1[E, T1 any](t T.Tuple1[IOEither[E, T1]]) IOEither[E, T.Tuple1[T1]]

SequenceTuple1 converts a [T.Tuple1[IOEither[E, T]]] into a [IOEither[E, T.Tuple1[T1]]]

func SequenceTuple10 added in v1.0.7

func SequenceTuple10[E, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](t T.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, T.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]

SequenceTuple10 converts a [T.Tuple10[IOEither[E, T]]] into a [IOEither[E, T.Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]]]

func SequenceTuple2 added in v1.0.7

func SequenceTuple2[E, T1, T2 any](t T.Tuple2[IOEither[E, T1], IOEither[E, T2]]) IOEither[E, T.Tuple2[T1, T2]]

SequenceTuple2 converts a [T.Tuple2[IOEither[E, T]]] into a [IOEither[E, T.Tuple2[T1, T2]]]

func SequenceTuple3 added in v1.0.7

func SequenceTuple3[E, T1, T2, T3 any](t T.Tuple3[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3]]) IOEither[E, T.Tuple3[T1, T2, T3]]

SequenceTuple3 converts a [T.Tuple3[IOEither[E, T]]] into a [IOEither[E, T.Tuple3[T1, T2, T3]]]

func SequenceTuple4 added in v1.0.7

func SequenceTuple4[E, T1, T2, T3, T4 any](t T.Tuple4[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4]]) IOEither[E, T.Tuple4[T1, T2, T3, T4]]

SequenceTuple4 converts a [T.Tuple4[IOEither[E, T]]] into a [IOEither[E, T.Tuple4[T1, T2, T3, T4]]]

func SequenceTuple5 added in v1.0.7

func SequenceTuple5[E, T1, T2, T3, T4, T5 any](t T.Tuple5[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5]]) IOEither[E, T.Tuple5[T1, T2, T3, T4, T5]]

SequenceTuple5 converts a [T.Tuple5[IOEither[E, T]]] into a [IOEither[E, T.Tuple5[T1, T2, T3, T4, T5]]]

func SequenceTuple6 added in v1.0.7

func SequenceTuple6[E, T1, T2, T3, T4, T5, T6 any](t T.Tuple6[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5], IOEither[E, T6]]) IOEither[E, T.Tuple6[T1, T2, T3, T4, T5, T6]]

SequenceTuple6 converts a [T.Tuple6[IOEither[E, T]]] into a [IOEither[E, T.Tuple6[T1, T2, T3, T4, T5, T6]]]

func SequenceTuple7 added in v1.0.7

func SequenceTuple7[E, T1, T2, T3, T4, T5, T6, T7 any](t T.Tuple7[IOEither[E, T1], IOEither[E, T2], IOEither[E, T3], IOEither[E, T4], IOEither[E, T5], IOEither[E, T6], IOEither[E, T7]]) IOEither[E, T.Tuple7[T1, T2, T3, T4, T5, T6, T7]]

SequenceTuple7 converts a [T.Tuple7[IOEither[E, T]]] into a [IOEither[E, T.Tuple7[T1, T2, T3, T4, T5, T6, T7]]]

func SequenceTuple8 added in v1.0.7

func SequenceTuple8[E, T1, T2, T3, T4, T5, T6, T7, T8 any](t T.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, T.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]

SequenceTuple8 converts a [T.Tuple8[IOEither[E, T]]] into a [IOEither[E, T.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]]

func SequenceTuple9 added in v1.0.7

func SequenceTuple9[E, T1, T2, T3, T4, T5, T6, T7, T8, T9 any](t T.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, T.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]

SequenceTuple9 converts a [T.Tuple9[IOEither[E, T]]] into a [IOEither[E, T.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 TryCatch

func TryCatch[E, A any](f func() (A, error), onThrow func(error) E) IOEither[E, A]

func TryCatchError

func TryCatchError[A any](f func() (A, error)) IOEither[error, A]

Directories

Path Synopsis
Code generated by go generate; DO NOT EDIT.
Code generated by go generate; DO NOT EDIT.
di

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL