ioeither

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Apache-2.0 Imports: 7 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ap

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

func ApFirst

func ApFirst[E, A, 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 ApSecond

func ApSecond[E, A, 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 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 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 monad returned by the function but returns the result of the original monad

func ChainFirstIOK

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

ChainFirsIOKt runs the 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 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[E, A, B any](fb IOEither[E, B]) func(IOEither[E, A]) IOEither[E, B]

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

func Eitherize0

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

func Eitherize1

func Eitherize1[T1, A any](f func(t1 T1) (A, error)) func(T1) IOEither[error, A]

func Eitherize2

func Eitherize2[T1, T2, A any](f func(t1 T1, t2 T2) (A, error)) func(T1, T2) IOEither[error, A]

func Eitherize3

func Eitherize3[T1, T2, T3, A any](f func(t1 T1, t2 T2, t3 T3) (A, error)) func(T1, T2, T3) IOEither[error, A]

func Eitherize4

func Eitherize4[T1, T2, T3, T4, A any](f func(t1 T1, t2 T2, t3 T3, t4 T4) (A, error)) func(T1, T2, T3, T4) IOEither[error, A]

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 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 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` 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 Map

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

func MapLeft

func MapLeft[E1, E2, A 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 TraverseArray

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

TraverseArray 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 WithResource

func WithResource[E, R, A, 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]]

IO represents a synchronous computation that may fail refer to [https://andywhite.xyz/posts/2021-01-27-rte-foundations/#ioeitherlte-agt] for more details

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

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

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]

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

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

func MonadApFirst

func MonadApFirst[E, A, 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 MonadApSecond

func MonadApSecond[E, A, 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 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 monad returned by the function but returns the result of the original monad

func MonadChainFirstIOK

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

MonadChainFirstIOK runs 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[E, A, 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 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 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 SequenceT1

func SequenceT1[E, A any](a IOEither[E, A]) IOEither[E, T.Tuple1[A]]

func SequenceT2

func SequenceT2[E, A, B any](
	a IOEither[E, A],
	b IOEither[E, B],
) IOEither[E, T.Tuple2[A, B]]

func SequenceT3

func SequenceT3[E, A, B, C any](
	a IOEither[E, A],
	b IOEither[E, B],
	c IOEither[E, C],
) IOEither[E, T.Tuple3[A, B, C]]

func SequenceT4

func SequenceT4[E, A, B, C, D any](
	a IOEither[E, A],
	b IOEither[E, B],
	c IOEither[E, C],
	d IOEither[E, D],
) IOEither[E, T.Tuple4[A, B, C, D]]

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

Jump to

Keyboard shortcuts

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