Documentation
¶
Overview ¶
Package result implements the Result type.
Index ¶
- func After[A any](dur time.Duration, a A) warp.Result[A]
- func Ap[A, B any](fab warp.Result[func(A) B], fa warp.Result[A]) warp.Result[B]
- func ApFirst[A, B any](fa warp.Result[A], fb warp.Result[B]) warp.Result[A]
- func ApSecond[A, B any](fa warp.Result[A], fb warp.Result[B]) warp.Result[B]
- func Bimap[A, B any](fa warp.Result[A], f func(error) error, g func(A) B) warp.Result[B]
- func Chain[A, B any](ma warp.Result[A], f func(A) warp.Result[B]) warp.Result[B]
- func ChainFirst[A, B any](ma warp.Result[A], f func(A) warp.Result[B]) warp.Result[A]
- func Error[A any](err error) warp.Result[A]
- func ErrorAfter[A any](dur time.Duration, err error) warp.Result[A]
- func FilterOrElse[A any](ma warp.Result[A], predicate warp.Predicate[A], onFalse func(A) error) warp.Result[A]
- func Fork[A any](ctx context.Context, ma warp.Result[A], onError func(error), onSuccess func(A))
- func FromNilable[A any](ma warp.Nilable[A], onNil func() error) warp.Result[A]
- func FromResult[A any](result warp.Result[A]) (r warp.Result[A])
- func FromResult1[A, I any](f func(context.Context, I) (A, error), i I) warp.Result[A]
- func GetOrElse[A any](ctx context.Context, ma warp.Result[A], onError func(error) A) A
- func Map[A, B any](fa warp.Result[A], f func(A) B) warp.Result[B]
- func MapError[A any](fa warp.Result[A], f func(error) error) warp.Result[A]
- func Ok[A any](a A) warp.Result[A]
- func OrElse[A any](ma warp.Result[A], onError func(error) warp.Result[A]) warp.Result[A]
- func Reduce[A, B any](ctx context.Context, ma warp.Result[A], onError func(error) B, ...) B
- func Zero[A any]() warp.Result[A]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ap ¶
Ap creates a result by applying a function contained in the first result on the value contained in the second result.
func ApFirst ¶
ApFirst creates a result by combining two effectful computations, keeping only the result of the first.
func ApSecond ¶
ApSecond creates a result by combining two effectful computations, keeping only the result of the second.
func Bimap ¶
Bimap creates a result by mapping a pair of functions over an error or a value contained in a result.
func Chain ¶
Chain creates a result which combines two results in sequence, using the return value of one result to determine the next one.
func ChainFirst ¶
ChainFirst composes two results in sequence, using the return value of one result to determine the next one, keeping only the first result.
func FilterOrElse ¶
func FilterOrElse[A any](ma warp.Result[A], predicate warp.Predicate[A], onFalse func(A) error) warp.Result[A]
FilterOrElse creates a result which can be used to fail with an error unless a predicate holds on a succeeding result.
func FromNilable ¶
FromNilable creates a result from a nilable, returning the supplied error for nil values.
func FromResult1 ¶
func GetOrElse ¶
GetOrElse creates a result which can be used to recover from a failing result with a new value.
func OrElse ¶
OrElse creates a result which can be used to recover from a failing result by switching to a new result.
Types ¶
This section is empty.