Help us shape the future of Go! Take the 2026 Go Developer Survey

generic

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ap

func Ap[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], GAB ~func() ET.Either[E, func(A) B], E, A, B any](ma GA) func(GAB) GB

func ApFirst

func ApFirst[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], GBA ~func() ET.Either[E, func(B) A], E, A, B any](second GB) func(GA) GA

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

func ApPar added in v1.0.4

func ApPar[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], GAB ~func() ET.Either[E, func(A) B], E, A, B any](ma GA) func(GAB) GB

func ApSecond

func ApSecond[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], GBB ~func() ET.Either[E, func(B) B], E, A, B any](second GB) func(GA) GB

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

func ApSeq added in v1.0.4

func ApSeq[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], GAB ~func() ET.Either[E, func(A) B], E, A, B any](ma GA) func(GAB) GB

func BiMap

func BiMap[GA ~func() ET.Either[E1, A], GB ~func() ET.Either[E2, B], E1, E2, A, B any](f func(E1) E2, g func(A) B) func(GA) GB

BiMap maps a pair of functions over the two type arguments of the bifunctor.

func Bracket

func Bracket[
	GA ~func() ET.Either[E, A],
	GB ~func() ET.Either[E, B],
	GANY ~func() ET.Either[E, ANY],
	E, A, B, ANY any](

	acquire GA,
	use func(A) GB,
	release func(A, ET.Either[E, B]) GANY,
) GB

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 Chain

func Chain[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], E, A, B any](f func(A) GB) func(GA) GB

func ChainEitherK

func ChainEitherK[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], E, A, B any](f func(A) ET.Either[E, B]) func(GA) GB

func ChainFirst

func ChainFirst[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], E, A, B any](f func(A) GB) func(GA) GA

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

func ChainFirstIOK

func ChainFirstIOK[GA ~func() ET.Either[E, A], GIOB ~func() B, E, A, B any](f func(A) GIOB) func(GA) GA

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

func ChainIOK

func ChainIOK[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], GR ~func() B, E, A, B any](f func(A) GR) func(GA) GB

func ChainOptionK

func ChainOptionK[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], E, A, B any](onNone func() E) func(func(A) O.Option[B]) func(GA) GB

func ChainTo

func ChainTo[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], E, A, B any](fb GB) func(GA) GB

func Command

func Command[GA ~func() ET.Either[error, exec.CommandOutput]](name string, args []string, in []byte) GA

Command executes a command

func Defer

func Defer[GEA ~func() ET.Either[E, A], E, A any](gen func() GEA) GEA

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

func Delay

func Delay[GA ~func() ET.Either[E, A], E, A any](delay time.Duration) func(GA) GA

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

func Eitherize0

func Eitherize0[GEA ~func() ET.Either[error, A], GA ~func() (A, error), A any](f GA) func() GEA

func Eitherize1

func Eitherize1[GEA ~func() ET.Either[error, A], GA ~func(t1 T1) (A, error), T1, A any](f GA) func(T1) GEA

func Eitherize2

func Eitherize2[GEA ~func() ET.Either[error, A], GA ~func(t1 T1, t2 T2) (A, error), T1, T2, A any](f GA) func(T1, T2) GEA

func Eitherize3

func Eitherize3[GEA ~func() ET.Either[error, A], GA ~func(t1 T1, t2 T2, t3 T3) (A, error), T1, T2, T3, A any](f GA) func(T1, T2, T3) GEA

func Eitherize4

func Eitherize4[GEA ~func() ET.Either[error, A], GA ~func(t1 T1, t2 T2, t3 T3, t4 T4) (A, error), T1, T2, T3, T4, A any](f GA) func(T1, T2, T3, T4) GEA

func Eq

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

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

func Flatten

func Flatten[GA ~func() ET.Either[E, A], GAA ~func() ET.Either[E, GA], E, A any](mma GAA) GA

func Fold

func Fold[GA ~func() ET.Either[E, A], GB ~func() B, E, A, B any](onLeft func(E) GB, onRight func(A) GB) func(GA) GB

Fold convers an IOEither into an IO

func FromEither

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

func FromIO

func FromIO[GA ~func() ET.Either[E, A], GR ~func() A, E, A any](mr GR) GA

func FromImpure

func FromImpure[GA ~func() ET.Either[E, any], IMP ~func(), E any](f IMP) GA

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

func FromOption

func FromOption[GA ~func() ET.Either[E, A], E, A any](onNone func() E) func(o O.Option[A]) GA

func FromStrictEquals

func FromStrictEquals[GA ~func() ET.Either[E, A], E, A comparable]() EQ.Eq[GA]

FromStrictEquals constructs an `Eq` from the canonical comparison function

func GetOrElse

func GetOrElse[GA ~func() ET.Either[E, A], GB ~func() A, E, A any](onLeft func(E) GB) func(GA) GB

GetOrElse extracts the value or maps the error

func Left

func Left[GA ~func() ET.Either[E, A], E, A any](l E) GA

func LeftIO

func LeftIO[GA ~func() ET.Either[E, A], GE ~func() E, E, A any](ml GE) GA

func MakeIO

func MakeIO[GA ~func() ET.Either[E, A], E, A any](f GA) GA

func Map

func Map[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], E, A, B any](f func(A) B) func(GA) GB

func MapLeft

func MapLeft[GA1 ~func() ET.Either[E1, A], GA2 ~func() ET.Either[E2, A], E1, E2, A any](f func(E1) E2) func(GA1) GA2

func MapTo

func MapTo[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], E, A, B any](b B) func(GA) GB

func Memoize

func Memoize[GA ~func() ET.Either[E, A], E, A any](ma GA) GA

Memoize computes the value of the provided IO monad lazily but exactly once

func MonadAp

func MonadAp[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], GAB ~func() ET.Either[E, func(A) B], E, A, B any](mab GAB, ma GA) GB

func MonadApFirst

func MonadApFirst[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], GBA ~func() ET.Either[E, func(B) A], E, A, B any](first GA, second GB) GA

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

func MonadApPar added in v1.0.4

func MonadApPar[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], GAB ~func() ET.Either[E, func(A) B], E, A, B any](mab GAB, ma GA) GB

func MonadApSecond

func MonadApSecond[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], GBB ~func() ET.Either[E, func(B) B], E, A, B any](first GA, second GB) GB

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

func MonadApSeq added in v1.0.4

func MonadApSeq[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], GAB ~func() ET.Either[E, func(A) B], E, A, B any](mab GAB, ma GA) GB

func MonadBiMap

func MonadBiMap[GA ~func() ET.Either[E1, A], GB ~func() ET.Either[E2, B], E1, E2, A, B any](fa GA, f func(E1) E2, g func(A) B) GB

func MonadChain

func MonadChain[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], E, A, B any](fa GA, f func(A) GB) GB

func MonadChainEitherK

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

func MonadChainFirst

func MonadChainFirst[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], E, A, B any](ma GA, f func(A) GB) GA

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

func MonadChainFirstIOK

func MonadChainFirstIOK[GA ~func() ET.Either[E, A], GIOB ~func() B, E, A, B any](first GA, f func(A) GIOB) GA

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

func MonadChainIOK

func MonadChainIOK[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], GR ~func() B, E, A, B any](ma GA, f func(A) GR) GB

func MonadChainTo

func MonadChainTo[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], E, A, B any](fa GA, fb GB) GB

func MonadFold

func MonadFold[GA ~func() ET.Either[E, A], GB ~func() B, E, A, B any](ma GA, onLeft func(E) GB, onRight func(A) GB) GB

func MonadMap

func MonadMap[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], E, A, B any](fa GA, f func(A) B) GB

func MonadMapLeft

func MonadMapLeft[GA1 ~func() ET.Either[E1, A], GA2 ~func() ET.Either[E2, A], E1, E2, A any](fa GA1, f func(E1) E2) GA2

func MonadMapTo

func MonadMapTo[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], E, A, B any](fa GA, b B) GB

func MonadOf

func MonadOf[GA ~func() ET.Either[E, A], E, A any](r A) GA

func MonadTraverseArray

func MonadTraverseArray[GB ~func() ET.Either[E, B], GBS ~func() ET.Either[E, BBS], AAS ~[]A, BBS ~[]B, E, A, B any](tas AAS, f func(A) GB) GBS

MonadTraverseArray transforms an array

func MonadTraverseRecord

func MonadTraverseRecord[GB ~func() ET.Either[E, B], GBS ~func() ET.Either[E, BBS], AAS ~map[K]A, BBS ~map[K]B, K comparable, E, A, B any](tas AAS, f func(A) GB) GBS

MonadTraverseRecord transforms an array

func Of

func Of[GA ~func() ET.Either[E, A], E, A any](r A) GA

func Retrying

func Retrying[GA ~func() ET.Either[E, A], E, A any](
	policy R.RetryPolicy,
	action func(R.RetryStatus) GA,
	check func(ET.Either[E, A]) bool,
) GA

Retry combinator for actions that don't raise exceptions, but signal in their type the outcome has failed. Examples are the `Option`, `Either` and `EitherT` monads.

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[GA ~func() ET.Either[E, A], E, A any](r A) GA

func RightIO

func RightIO[GA ~func() ET.Either[E, A], GR ~func() A, E, A any](mr GR) GA

func SequenceArray

func SequenceArray[GA ~func() ET.Either[E, A], GAS ~func() ET.Either[E, AAS], AAS ~[]A, GAAS ~[]GA, E, A any](tas GAAS) GAS

SequenceArray converts a homogeneous sequence of either into an either of sequence

func SequenceRecord

func SequenceRecord[GA ~func() ET.Either[E, A], GAS ~func() ET.Either[E, AAS], AAS ~map[K]A, GAAS ~map[K]GA, K comparable, E, A any](tas GAAS) GAS

SequenceRecord converts a homogeneous sequence of either into an either of sequence

func SequenceT1

func SequenceT1[GA ~func() ET.Either[E, A], GTA ~func() ET.Either[E, T.Tuple1[A]], E, A any](a GA) GTA

func SequenceT2

func SequenceT2[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], GTAB ~func() ET.Either[E, T.Tuple2[A, B]], E, A, B any](a GA, b GB) GTAB

func SequenceT3

func SequenceT3[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], GC ~func() ET.Either[E, C], GTABC ~func() ET.Either[E, T.Tuple3[A, B, C]], E, A, B, C any](a GA, b GB, c GC) GTABC

func SequenceT4

func SequenceT4[GA ~func() ET.Either[E, A], GB ~func() ET.Either[E, B], GC ~func() ET.Either[E, C], GD ~func() ET.Either[E, D], GTABCD ~func() ET.Either[E, T.Tuple4[A, B, C, D]], E, A, B, C, D any](a GA, b GB, c GC, d GD) GTABCD

func Swap

func Swap[GEA ~func() ET.Either[E, A], GAE ~func() ET.Either[A, E], E, A any](val GEA) GAE

Swap changes the order of type parameters

func TraverseArray

func TraverseArray[GB ~func() ET.Either[E, B], GBS ~func() ET.Either[E, BBS], AAS ~[]A, BBS ~[]B, E, A, B any](f func(A) GB) func(AAS) GBS

TraverseArray transforms an array

func TraverseRecord

func TraverseRecord[GB ~func() ET.Either[E, B], GBS ~func() ET.Either[E, BBS], AAS ~map[K]A, BBS ~map[K]B, K comparable, E, A, B any](f func(A) GB) func(AAS) GBS

TraverseRecord transforms an array

func TryCatch

func TryCatch[GA ~func() ET.Either[E, A], E, A any](f func() (A, error), onThrow func(error) E) GA

func TryCatchError

func TryCatchError[GA ~func() ET.Either[error, A], A any](f func() (A, error)) GA

func Uneitherize0

func Uneitherize0[GEA ~func() ET.Either[error, A], GTA ~func() GEA, A any](f GTA) func() (A, error)

func Uneitherize1

func Uneitherize1[GEA ~func() ET.Either[error, A], GTA ~func(t1 T1) GEA, T1, A any](f GTA) func(T1) (A, error)

func Uneitherize2

func Uneitherize2[GEA ~func() ET.Either[error, A], GTA ~func(t1 T1, t2 T2) GEA, T1, T2, A any](f GTA) func(T1, T2) (A, error)

func Uneitherize3

func Uneitherize3[GEA ~func() ET.Either[error, A], GTA ~func(t1 T1, t2 T2, t3 T3) GEA, T1, T2, T3, A any](f GTA) func(T1, T2, T3) (A, error)

func Uneitherize4

func Uneitherize4[GEA ~func() ET.Either[error, A], GTA ~func(t1 T1, t2 T2, t3 T3, t4 T4) GEA, T1, T2, T3, T4, A any](f GTA) func(T1, T2, T3, T4) (A, error)

func WithResource

func WithResource[
	GA ~func() ET.Either[E, A],
	GR ~func() ET.Either[E, R],
	GANY ~func() ET.Either[E, ANY],
	E, R, A, ANY any](onCreate GR, onRelease func(R) GANY) func(func(R) GA) GA

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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