Documentation
¶
Overview ¶
Package result is the railway type of Go+: a computation that either produced a value (Ok) or failed (Err). It is authored in Go+ and distributed as generated Go — consumers never need the goplus toolchain.
Index ¶
- func Fold[T any, E any, R any](v Result[T, E], cs ResultCases[T, E, R]) R
- func IsErr[T any, E any](r Result[T, E]) bool
- func IsOk[T any, E any](r Result[T, E]) bool
- func Unpack[T any, E any](r Result[T, E]) (T, E)
- func UnwrapOr[T any, E any](r Result[T, E], fallback T) T
- type Err
- type Ok
- type Result
- func Bind[T any, E any, U any](r Result[T, E], f func(T) Result[U, E]) Result[U, E]
- func Map[T any, E any, U any](r Result[T, E], f func(T) U) Result[U, E]
- func MapError[T any, E any, F any](r Result[T, E], f func(E) F) Result[T, F]
- func Of[T any](v T, err error) Result[T, error]
- func Tee[T any, E any](r Result[T, E], f func(T)) Result[T, E]
- type ResultCases
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fold ¶
func Fold[T any, E any, R any](v Result[T, E], cs ResultCases[T, E, R]) R
Fold reduces Result[T, E] by one-level case analysis.
Types ¶
type Result ¶
Result carries one success value or one failure value.
func Bind ¶
Bind connects a switch function onto the railway: applied to the Ok value; an Err bypasses it.
type ResultCases ¶
ResultCases selects one handler per Result variant for Fold.
Click to show internal directories.
Click to hide internal directories.