result

package
v0.0.0-...-0e61b49 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 1 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func For

func For[A any](res Result[A], f func(a A))

func ForErr

func ForErr[A any](res Result[A], f func(error))

func Get

func Get[A any](res Result[A]) A

func GetErr

func GetErr[A any](res Result[A]) error

func IsErr

func IsErr[A any](res Result[A]) bool

func IsOK

func IsOK[A any](res Result[A]) bool

func NewResultApplicative

func NewResultApplicative[A any]() *resultApplicative[A]

func NewResultFunctor

func NewResultFunctor[A, B any]() *resultFunctor[A, B]

func Unpack

func Unpack[A any](res Result[A]) (A, error)

Types

type Err

type Err[A any] struct {
	Error error
}

func (Err[A]) ElemType

func (Err[A]) ElemType(A)

func (Err[A]) Kind

func (Err[A]) Kind(ResultKind)

type Ok

type Ok[A any] struct {
	Value A
}

func (Ok[A]) ElemType

func (Ok[A]) ElemType(A)

func (Ok[A]) Kind

func (Ok[A]) Kind(ResultKind)

type Result

type Result[A any] types.HKT[ResultKind, A]

func AndThen

func AndThen[A, B any](res Result[A], f func(A) Result[B]) Result[B]

func FlatMap

func FlatMap[A, B any](res Result[A], f func(A) Result[B]) Result[B]

func From

func From[A any](x A) Result[A]

func FromErr

func FromErr[A any](err error) Result[A]

func Map

func Map[A, B any](res Result[A], f func(A) B) Result[B]

func MapErr

func MapErr[A any](res Result[A], f func(error) error) Result[A]

type ResultKind

type ResultKind types.Kind

Jump to

Keyboard shortcuts

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