either

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists[L, R any](predicate func(right R) bool) func(Either[L, R]) bool

func FromOption

func FromOption[L, R any](onNone func() L) func(o opt.Option[R]) Either[L, R]

func FromPredicate

func FromPredicate[L, R any](predicate func(value R) bool, onLeft func() L) func(R) Either[L, R]

func GetOrElse

func GetOrElse[L, R any](onLeft func(left L) R) func(Either[L, R]) R

func IsLeft

func IsLeft[L, R any](e Either[L, R]) bool

func IsRight

func IsRight[L, R any](e Either[L, R]) bool

func Map

func Map[L, R, T any](onRight func(right R) T) func(Either[L, R]) Either[L, T]

func MapLeft

func MapLeft[L, R, T any](fn func(left L) T) func(Either[L, R]) Either[T, R]

func Match

func Match[L, R, T any](onLeft func(left L) T, onRight func(right R) T) func(Either[L, R]) T

Types

type Either

type Either[L, R any] struct {
	// contains filtered or unexported fields
}

Base struct

func Flatten

func Flatten[L, R any](e Either[L, Either[L, R]]) Either[L, R]

func FromError

func FromError[R any](value R, e error) Either[error, R]

func FromErrorFn

func FromErrorFn[R any](fn func() (value R, e error)) Either[error, R]

func Left

func Left[L, R any](value L) Either[L, R]
func Right[L, R any](value R) Either[L, R]

Jump to

Keyboard shortcuts

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