io

package
v1.0.3 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: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Now = G.Now[IO[time.Time]]()

Now returns the current timestamp

Functions

func Ap

func Ap[B, A any](ma IO[A]) func(IO[func(A) B]) IO[B]

func ApFirst

func ApFirst[A, B any](second IO[B]) func(IO[A]) IO[A]

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

func ApSecond

func ApSecond[A, B any](second IO[B]) func(IO[A]) IO[B]

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

func ApplicativeMonoid

func ApplicativeMonoid[A any](m M.Monoid[A]) M.Monoid[IO[A]]

func ApplySemigroup

func ApplySemigroup[A any](s S.Semigroup[A]) S.Semigroup[IO[A]]

func Chain

func Chain[A, B any](f func(A) IO[B]) func(IO[A]) IO[B]

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

func ChainFirst

func ChainFirst[A, B any](f func(A) IO[B]) func(IO[A]) IO[A]

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[A, B any](fb IO[B]) func(IO[A]) IO[B]

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

func Eq

func Eq[A any](e EQ.Eq[A]) EQ.Eq[IO[A]]

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

func Logf

func Logf[A any](prefix string) func(A) IO[any]

Logf constructs a logger function that can be used with ChainXXXIOK the string prefix contains the format string for the log value

func Logger

func Logger[A any](loggers ...*log.Logger) func(string) func(A) IO[any]

Logger constructs a logger function that can be used with ChainXXXIOK

func Map

func Map[A, B any](f func(A) B) func(fa IO[A]) IO[B]

func MapTo

func MapTo[A, B any](b B) func(IO[A]) IO[B]

func TraverseArray

func TraverseArray[A, B any](f func(A) IO[B]) func([]A) IO[[]B]

TraverseArray applies a function returning an IO to all elements in an array and the transforms this into an IO of that array

func TraverseRecord

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

TraverseArray applies a function returning an IO to all elements in a record and the transforms this into an IO of that record

Types

type IO

type IO[A any] func() A

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

func Defer

func Defer[A any](gen func() IO[A]) IO[A]

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

func Flatten

func Flatten[A any](mma IO[IO[A]]) IO[A]

func FromIO

func FromIO[A any](a IO[A]) IO[A]

func FromImpure

func FromImpure(f func()) IO[any]

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

func MakeIO

func MakeIO[A any](f func() A) IO[A]

func Memoize

func Memoize[A any](ma IO[A]) IO[A]

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

func MonadAp

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

func MonadApFirst

func MonadApFirst[A, B any](first IO[A], second IO[B]) IO[A]

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

func MonadApSecond

func MonadApSecond[A, B any](first IO[A], second IO[B]) IO[B]

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

func MonadChain

func MonadChain[A, B any](fa IO[A], f func(A) IO[B]) IO[B]

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

func MonadChainFirst

func MonadChainFirst[A, B any](fa IO[A], f func(A) IO[B]) IO[A]

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[A, B any](fa IO[A], fb IO[B]) IO[B]

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

func MonadMap

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

func MonadMapTo

func MonadMapTo[A, B any](fa IO[A], b B) IO[B]

func MonadOf

func MonadOf[A any](a A) IO[A]

func MonadTraverseArray

func MonadTraverseArray[A, B any](tas []A, f func(A) IO[B]) IO[[]B]

func MonadTraverseRecord

func MonadTraverseRecord[K comparable, A, B any](tas map[K]A, f func(A) IO[B]) IO[map[K]B]

func Of

func Of[A any](a A) IO[A]

func Retrying

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

SequenceArray converts an array of IO to an IO of an array

func SequenceRecord

func SequenceRecord[K comparable, A any](tas map[K]IO[A]) IO[map[K]A]

SequenceRecord converts a record of IO to an IO of a record

func SequenceT1

func SequenceT1[A any](a IO[A]) IO[T.Tuple1[A]]

func SequenceT2

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

func SequenceT3

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

func SequenceT4

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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