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

readereither

package
v1.1.84 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package readereither implements a specialization of the Reader monad assuming a golang context as the context of the monad and a standard golang error

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ap

func Ap[A, B any](fa ReaderEither[A]) func(ReaderEither[func(A) B]) ReaderEither[B]

func ApS added in v1.0.107

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

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

func Bind added in v1.0.107

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

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

func BindTo added in v1.0.107

func BindTo[S1, T any](
	setter func(T) S1,
) func(ReaderEither[T]) ReaderEither[S1]

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

func Chain

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

func ChainEitherK

func ChainEitherK[A, B any](f func(A) ET.Either[error, B]) func(ma ReaderEither[A]) ReaderEither[B]

func ChainOptionK

func ChainOptionK[A, B any](onNone func() error) func(func(A) O.Option[B]) func(ReaderEither[A]) ReaderEither[B]

func Curry1

func Curry1[T1, A any](f func(context.Context, T1) (A, error)) func(T1) ReaderEither[A]

func Curry2

func Curry2[T1, T2, A any](f func(context.Context, T1, T2) (A, error)) func(T1) func(T2) ReaderEither[A]

func Curry3

func Curry3[T1, T2, T3, A any](f func(context.Context, T1, T2, T3) (A, error)) func(T1) func(T2) func(T3) ReaderEither[A]

func Flap added in v1.0.47

func Flap[B, A any](a A) func(ReaderEither[func(A) B]) ReaderEither[B]

func From0

func From0[A any](f func(context.Context) (A, error)) func() ReaderEither[A]

func From1

func From1[T1, A any](f func(context.Context, T1) (A, error)) func(T1) ReaderEither[A]

func From2

func From2[T1, T2, A any](f func(context.Context, T1, T2) (A, error)) func(T1, T2) ReaderEither[A]

func From3

func From3[T1, T2, T3, A any](f func(context.Context, T1, T2, T3) (A, error)) func(T1, T2, T3) ReaderEither[A]

func FromPredicate

func FromPredicate[A any](pred func(A) bool, onFalse func(A) error) func(A) ReaderEither[A]

func Let added in v1.0.107

func Let[S1, S2, T any](
	setter func(T) func(S1) S2,
	f func(S1) T,
) func(ReaderEither[S1]) ReaderEither[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[S1, S2, T any](
	setter func(T) func(S1) S2,
	b T,
) func(ReaderEither[S1]) ReaderEither[S2]

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

func Map

func Map[A, B any](f func(A) B) func(ReaderEither[A]) ReaderEither[B]

func OrElse

func OrElse[A any](onLeft func(error) ReaderEither[A]) func(ReaderEither[A]) ReaderEither[A]

func TraverseArray

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

TraverseArray transforms an array

func TraverseArrayWithIndex added in v1.0.29

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

TraverseArrayWithIndex transforms an array

func Uncurry1

func Uncurry1[T1, A any](f func(T1) ReaderEither[A]) func(context.Context, T1) (A, error)

func Uncurry2

func Uncurry2[T1, T2, A any](f func(T1) func(T2) ReaderEither[A]) func(context.Context, T1, T2) (A, error)

func Uncurry3

func Uncurry3[T1, T2, T3, A any](f func(T1) func(T2) func(T3) ReaderEither[A]) func(context.Context, T1, T2, T3) (A, error)

Types

type ReaderEither

type ReaderEither[A any] RE.ReaderEither[context.Context, error, A]

ReaderEither is a specialization of the Reader monad for the typical golang scenario

func Ask

func Curry0

func Curry0[A any](f func(context.Context) (A, error)) ReaderEither[A]

func Do added in v1.0.107

func Do[S any](
	empty S,
) ReaderEither[S]

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

func FromEither

func FromEither[A any](e ET.Either[error, A]) ReaderEither[A]

func Left

func Left[A any](l error) ReaderEither[A]

func MakeReaderEither

func MakeReaderEither[A any](f func(context.Context) ET.Either[error, A]) ReaderEither[A]

func MonadAp

func MonadAp[A, B any](fab ReaderEither[func(A) B], fa ReaderEither[A]) ReaderEither[B]

func MonadChain

func MonadChain[A, B any](ma ReaderEither[A], f func(A) ReaderEither[B]) ReaderEither[B]

func MonadChainEitherK

func MonadChainEitherK[A, B any](ma ReaderEither[A], f func(A) ET.Either[error, B]) ReaderEither[B]

func MonadFlap added in v1.0.47

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

func MonadMap

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

func Of

func Of[A any](a A) ReaderEither[A]
func Right[A any](r A) ReaderEither[A]

func SequenceArray

func SequenceArray[A any](ma []ReaderEither[A]) ReaderEither[[]A]

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

func SequenceT1

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

func SequenceT2

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

func SequenceT3

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

func SequenceT4

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

func WithContext

func WithContext[A any](ma ReaderEither[A]) ReaderEither[A]

withContext wraps an existing ReaderEither and performs a context check for cancellation before deletating

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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