Documentation ¶
Index ¶
- func Compose[T, U, V any](fn1 func(T) U, fn2 func(U) V) func(T) V
- func Empty[T any]() (t T)
- func ErrMapUp[E error](fn func(error) E) func(error) error
- func Id[T any](t T) T
- func If[Out, T any](r Option[T], someFn func(T) Out, noneFn func() Out) Out
- func Match[Out, T any](r Result[T], okFn func(T) Out, errFn func(error) Out) Out
- func Return[In any, T any](t T) func(In) T
- func Return0[T any](t T) func() T
- type ApplyToResult
- type ApplyToResult10
- type ApplyToResult2
- type ApplyToResult3
- type ApplyToResult4
- type ApplyToResult5
- type ApplyToResult6
- type ApplyToResult7
- type ApplyToResult8
- type ApplyToResult9
- type Option
- func (o Option[T]) AsPtr() *T
- func (o Option[T]) Expect(panicMsg string) T
- func (o Option[T]) IsNone() bool
- func (o Option[T]) IsSome() bool
- func (o Option[T]) Some(out *T) bool
- func (o Option[T]) Unwrap() T
- func (o Option[T]) UnwrapOr(defaultValue T) T
- func (o Option[T]) UnwrapOrElse(fn func() T) T
- type Result
- func AndThen[T, U any](r Result[T], fn func(T) Result[U]) Result[U]
- func Err[T any](err error) Result[T]
- func Map[T, U any](r Result[T], fn func(T) U) Result[U]
- func Map2[T, U, V any](r Result[T], s Result[U], fn func(T, U) V) Result[V]
- func Map3[T, U, V, W any](r Result[T], s Result[U], t Result[V], fn func(T, U, V) W) Result[W]
- func MapErr[T any, E error](fn func(error) E, r Result[T]) Result[T]
- func NewPtrResult[T any](value *T, err error) Result[T]
- func NewResult[T any](value T, err error) Result[T]
- func NewTupleResult[T, U any](first T, second U, err error) Result[Tuple[T, U]]
- func NewVoidResult(err error) Result[Void]
- func Ok[T any](value T) Result[T]
- func (r Result[T]) Err() Option[error]
- func (r Result[T]) Expect(panicMsg string) T
- func (r Result[T]) ExpectErr(panicMsg string) error
- func (r Result[T]) IsErr() bool
- func (r Result[T]) IsOk() bool
- func (r Result[T]) MapError(fn func(e error) error) Result[T]
- func (r Result[T]) Ok(out *T) error
- func (r Result[T]) Results() (*T, error)
- func (r Result[T]) ResultsMappingEmpty() (T, error)
- func (r Result[T]) Unwrap() T
- func (r Result[T]) UnwrapErr() error
- func (r Result[T]) UnwrapErrOr(defaultValue error) error
- func (r Result[T]) UnwrapOr(defaultValue T) T
- func (r Result[T]) UnwrapOrElse(fn func(error) T) T
- func (r Result[T]) Value() Option[T]
- func (r Result[T]) WrapErr(format string) Result[T]
- type Tuple
- type Void
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApplyToResult ¶
type ApplyToResult[Out, T any] struct { // contains filtered or unexported fields }
func Chain ¶
func Chain[Out, T any](result Result[T]) ApplyToResult[Out, T]
func (ApplyToResult[O, T]) AndThen ¶
func (a ApplyToResult[O, T]) AndThen(fn func(T) Result[O]) Result[O]
func (ApplyToResult[O, T]) Map ¶
func (a ApplyToResult[O, T]) Map(fn func(T) O) Result[O]
type ApplyToResult10 ¶
type ApplyToResult10[O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, T any] struct { // contains filtered or unexported fields }
func Chain10 ¶
func Chain10[Out10, Out9, Out8, Out7, Out6, Out5, Out4, Out3, Out2, Out1, T any](result Result[T]) ApplyToResult10[Out1, Out2, Out3, Out4, Out5, Out6, Out7, Out8, Out9, Out10, T]
func (ApplyToResult10[O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, T]) AndThen ¶
func (a ApplyToResult10[O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, T]) AndThen(fn func(T) Result[O1]) ApplyToResult9[O10, O9, O8, O7, O6, O5, O4, O3, O2, O1]
func (ApplyToResult10[O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, T]) Map ¶
func (a ApplyToResult10[O1, O2, O3, O4, O5, O6, O7, O8, O9, O10, T]) Map(fn func(T) O1) ApplyToResult9[O10, O9, O8, O7, O6, O5, O4, O3, O2, O1]
type ApplyToResult2 ¶
type ApplyToResult2[O1, O2, T any] struct { // contains filtered or unexported fields }
func Chain2 ¶
func Chain2[Out2, Out1, T any](result Result[T]) ApplyToResult2[Out1, Out2, T]
func (ApplyToResult2[O1, O2, T]) AndThen ¶
func (a ApplyToResult2[O1, O2, T]) AndThen(fn func(T) Result[O1]) ApplyToResult[O2, O1]
func (ApplyToResult2[O1, O2, T]) Map ¶
func (a ApplyToResult2[O1, O2, T]) Map(fn func(T) O1) ApplyToResult[O2, O1]
type ApplyToResult3 ¶
type ApplyToResult3[O1, O2, O3, T any] struct { // contains filtered or unexported fields }
func Chain3 ¶
func Chain3[Out3, Out2, Out1, T any](result Result[T]) ApplyToResult3[Out1, Out2, Out3, T]
func (ApplyToResult3[O1, O2, O3, T]) AndThen ¶
func (a ApplyToResult3[O1, O2, O3, T]) AndThen(fn func(T) Result[O1]) ApplyToResult2[O3, O2, O1]
func (ApplyToResult3[O1, O2, O3, T]) Map ¶
func (a ApplyToResult3[O1, O2, O3, T]) Map(fn func(T) O1) ApplyToResult2[O3, O2, O1]
type ApplyToResult4 ¶
type ApplyToResult4[O1, O2, O3, O4, T any] struct { // contains filtered or unexported fields }
func Chain4 ¶
func Chain4[Out4, Out3, Out2, Out1, T any](result Result[T]) ApplyToResult4[Out1, Out2, Out3, Out4, T]
func (ApplyToResult4[O1, O2, O3, O4, T]) AndThen ¶
func (a ApplyToResult4[O1, O2, O3, O4, T]) AndThen(fn func(T) Result[O1]) ApplyToResult3[O4, O3, O2, O1]
func (ApplyToResult4[O1, O2, O3, O4, T]) Map ¶
func (a ApplyToResult4[O1, O2, O3, O4, T]) Map(fn func(T) O1) ApplyToResult3[O4, O3, O2, O1]
type ApplyToResult5 ¶
type ApplyToResult5[O1, O2, O3, O4, O5, T any] struct { // contains filtered or unexported fields }
func Chain5 ¶
func Chain5[Out5, Out4, Out3, Out2, Out1, T any](result Result[T]) ApplyToResult5[Out1, Out2, Out3, Out4, Out5, T]
func (ApplyToResult5[O1, O2, O3, O4, O5, T]) AndThen ¶
func (a ApplyToResult5[O1, O2, O3, O4, O5, T]) AndThen(fn func(T) Result[O1]) ApplyToResult4[O5, O4, O3, O2, O1]
func (ApplyToResult5[O1, O2, O3, O4, O5, T]) Map ¶
func (a ApplyToResult5[O1, O2, O3, O4, O5, T]) Map(fn func(T) O1) ApplyToResult4[O5, O4, O3, O2, O1]
type ApplyToResult6 ¶
type ApplyToResult6[O1, O2, O3, O4, O5, O6, T any] struct { // contains filtered or unexported fields }
func Chain6 ¶
func Chain6[Out6, Out5, Out4, Out3, Out2, Out1, T any](result Result[T]) ApplyToResult6[Out1, Out2, Out3, Out4, Out5, Out6, T]
func (ApplyToResult6[O1, O2, O3, O4, O5, O6, T]) AndThen ¶
func (a ApplyToResult6[O1, O2, O3, O4, O5, O6, T]) AndThen(fn func(T) Result[O1]) ApplyToResult5[O6, O5, O4, O3, O2, O1]
func (ApplyToResult6[O1, O2, O3, O4, O5, O6, T]) Map ¶
func (a ApplyToResult6[O1, O2, O3, O4, O5, O6, T]) Map(fn func(T) O1) ApplyToResult5[O6, O5, O4, O3, O2, O1]
type ApplyToResult7 ¶
type ApplyToResult7[O1, O2, O3, O4, O5, O6, O7, T any] struct { // contains filtered or unexported fields }
func Chain7 ¶
func Chain7[Out7, Out6, Out5, Out4, Out3, Out2, Out1, T any](result Result[T]) ApplyToResult7[Out1, Out2, Out3, Out4, Out5, Out6, Out7, T]
func (ApplyToResult7[O1, O2, O3, O4, O5, O6, O7, T]) AndThen ¶
func (a ApplyToResult7[O1, O2, O3, O4, O5, O6, O7, T]) AndThen(fn func(T) Result[O1]) ApplyToResult6[O7, O6, O5, O4, O3, O2, O1]
func (ApplyToResult7[O1, O2, O3, O4, O5, O6, O7, T]) Map ¶
func (a ApplyToResult7[O1, O2, O3, O4, O5, O6, O7, T]) Map(fn func(T) O1) ApplyToResult6[O7, O6, O5, O4, O3, O2, O1]
type ApplyToResult8 ¶
type ApplyToResult8[O1, O2, O3, O4, O5, O6, O7, O8, T any] struct { // contains filtered or unexported fields }
func Chain8 ¶
func Chain8[Out8, Out7, Out6, Out5, Out4, Out3, Out2, Out1, T any](result Result[T]) ApplyToResult8[Out1, Out2, Out3, Out4, Out5, Out6, Out7, Out8, T]
func (ApplyToResult8[O1, O2, O3, O4, O5, O6, O7, O8, T]) AndThen ¶
func (a ApplyToResult8[O1, O2, O3, O4, O5, O6, O7, O8, T]) AndThen(fn func(T) Result[O1]) ApplyToResult7[O8, O7, O6, O5, O4, O3, O2, O1]
func (ApplyToResult8[O1, O2, O3, O4, O5, O6, O7, O8, T]) Map ¶
func (a ApplyToResult8[O1, O2, O3, O4, O5, O6, O7, O8, T]) Map(fn func(T) O1) ApplyToResult7[O8, O7, O6, O5, O4, O3, O2, O1]
type ApplyToResult9 ¶
type ApplyToResult9[O1, O2, O3, O4, O5, O6, O7, O8, O9, T any] struct { // contains filtered or unexported fields }
func Chain9 ¶
func Chain9[Out9, Out8, Out7, Out6, Out5, Out4, Out3, Out2, Out1, T any](result Result[T]) ApplyToResult9[Out1, Out2, Out3, Out4, Out5, Out6, Out7, Out8, Out9, T]
func (ApplyToResult9[O1, O2, O3, O4, O5, O6, O7, O8, O9, T]) AndThen ¶
func (a ApplyToResult9[O1, O2, O3, O4, O5, O6, O7, O8, O9, T]) AndThen(fn func(T) Result[O1]) ApplyToResult8[O9, O8, O7, O6, O5, O4, O3, O2, O1]
func (ApplyToResult9[O1, O2, O3, O4, O5, O6, O7, O8, O9, T]) Map ¶
func (a ApplyToResult9[O1, O2, O3, O4, O5, O6, O7, O8, O9, T]) Map(fn func(T) O1) ApplyToResult8[O9, O8, O7, O6, O5, O4, O3, O2, O1]
type Option ¶
type Option[T any] struct { // contains filtered or unexported fields }
func (Option[T]) UnwrapOrElse ¶
func (o Option[T]) UnwrapOrElse(fn func() T) T
type Result ¶
type Result[T any] struct { // contains filtered or unexported fields }
Result[T] is a generic pseudo-enum, used for returning results with errors. The result type eliminates the need to return nil pointers, sentinal type zero values, or partial results when an error has occured. Instead, the result type can be in one of two states: Ok(T) or Err(error).
func NewPtrResult ¶
func NewTupleResult ¶
func NewVoidResult ¶
func (Result[T]) ResultsMappingEmpty ¶
ResultsMapEmpty maps the None case of the result value to an empty T (instead of a nil pointer to a T as is done by `Results()`)
func (Result[T]) UnwrapErrOr ¶
func (Result[T]) UnwrapOrElse ¶
Click to show internal directories.
Click to hide internal directories.