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: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ap

func Ap[GB ~func() B, GAB ~func() func(A) B, GA ~func() A, B, A any](ma GA) func(GAB) GB

func ApFirst

func ApFirst[GA ~func() A, GB ~func() B, GBA ~func() func(B) A, 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[GB ~func() B, GAB ~func() func(A) B, GA ~func() A, B, A any](ma GA) func(GAB) GB

func ApSecond

func ApSecond[GA ~func() A, GB ~func() B, GBB ~func() func(B) B, 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[GB ~func() B, GAB ~func() func(A) B, GA ~func() A, B, A any](ma GA) func(GAB) GB

func ApplicativeMonoid

func ApplicativeMonoid[GA ~func() A, A any](m M.Monoid[A]) M.Monoid[GA]

func ApplySemigroup

func ApplySemigroup[GA ~func() A, A any](s S.Semigroup[A]) S.Semigroup[GA]

func Chain

func Chain[GA ~func() A, GB ~func() B, A, B any](f func(A) GB) func(GA) GB

Chain composes computations in sequence, using the return value of one computation to determine the next computation.

func ChainFirst

func ChainFirst[GA ~func() A, GB ~func() B, A, B any](f func(A) GB) func(GA) GA

ChainFirst composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.

func ChainTo

func ChainTo[GA ~func() A, GB ~func() B, A, B any](fb GB) func(GA) GB

ChainTo composes computations in sequence, ignoring the return value of the first computation

func Defer

func Defer[GA ~func() A, A any](gen func() GA) GA

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

func Delay

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

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

func Eq

func Eq[GA ~func() A, A any](e EQ.Eq[A]) EQ.Eq[GA]

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

func Flatten

func Flatten[GA ~func() A, GAA ~func() GA, A any](mma GAA) GA

func FromIO

func FromIO[GA ~func() A, A any](a GA) GA

func FromImpure

func FromImpure[GA ~func() any, IMP ~func()](f IMP) GA

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

func Logf

func Logf[GA ~func() any, A any](prefix string) func(A) GA

func Logger

func Logger[GA ~func() any, A any](loggers ...*log.Logger) func(string) func(A) GA

func MakeIO

func MakeIO[GA ~func() A, A any](f func() A) GA

func Map

func Map[GA ~func() A, GB ~func() B, A, B any](f func(A) B) func(GA) GB

func MapTo

func MapTo[GA ~func() A, GB ~func() B, A, B any](b B) func(GA) GB

func Memoize

func Memoize[GA ~func() A, A any](ma GA) GA

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

func MonadAp

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

MonadAp implements the `ap` operation. Depending on a feature flag this will be sequential or parallel, the preferred implementation is parallel

func MonadApFirst

func MonadApFirst[GA ~func() A, GB ~func() B, GBA ~func() func(B) A, 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() A, GB ~func() B, GAB ~func() func(A) B, A, B any](mab GAB, ma GA) GB

MonadApPar implements the applicative on two threads, the main thread executes mab and the actuall apply operation and the second thred computes ma. Communication between the threads happens via a channel

func MonadApSecond

func MonadApSecond[GA ~func() A, GB ~func() B, GBB ~func() func(B) B, 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() A, GB ~func() B, GAB ~func() func(A) B, A, B any](mab GAB, ma GA) GB

MonadApSeq implements the applicative on a single thread by first executing mab and the ma

func MonadChain

func MonadChain[GA ~func() A, GB ~func() B, A, B any](fa GA, f func(A) GB) GB

MonadChain composes computations in sequence, using the return value of one computation to determine the next computation.

func MonadChainFirst

func MonadChainFirst[GA ~func() A, GB ~func() B, A, B any](fa GA, f func(A) GB) GA

MonadChainFirst composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.

func MonadChainTo

func MonadChainTo[GA ~func() A, GB ~func() B, A, B any](fa GA, fb GB) GB

MonadChainTo composes computations in sequence, ignoring the return value of the first computation

func MonadMap

func MonadMap[GA ~func() A, GB ~func() B, A, B any](fa GA, f func(A) B) GB

func MonadMapTo

func MonadMapTo[GA ~func() A, GB ~func() B, A, B any](fa GA, b B) GB

func MonadOf

func MonadOf[GA ~func() A, A any](a A) GA

func MonadTraverseArray

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

func MonadTraverseRecord

func MonadTraverseRecord[GB ~func() B, GBS ~func() MB, MA ~map[K]A, MB ~map[K]B, K comparable, A, B any](ma MA, f func(A) GB) GBS

MonadTraverseRecord transforms a record using an IO transform an IO of a record

func Now

func Now[GA ~func() time.Time]() GA

Now returns the current timestamp

func Of

func Of[GA ~func() A, A any](a A) GA

func Printf added in v1.0.6

func Printf[GA ~func() any, A any](prefix string) func(A) GA

func Retrying

func Retrying[GA ~func() A, A any](
	policy R.RetryPolicy,
	action func(R.RetryStatus) GA,
	check func(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 SequenceArray

func SequenceArray[GA ~func() A, GAS ~func() AAS, AAS ~[]A, GAAS ~[]GA, A any](tas GAAS) GAS

func SequenceRecord

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

func SequenceT1

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

func SequenceT2

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

func SequenceT3

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

func SequenceT4

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

func TraverseArray

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

func TraverseRecord

func TraverseRecord[GB ~func() B, GBS ~func() MB, MA ~map[K]A, MB ~map[K]B, K comparable, A, B any](f func(A) GB) func(MA) GBS

TraverseRecord transforms a record using an IO transform an IO of a record

Types

This section is empty.

Jump to

Keyboard shortcuts

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