either

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[L, R any](e lang.Either[L, R], f func(R) bool) lang.Either[L, R]

func FlatMap

func FlatMap[L, R, R1 any](e lang.Either[L, R], f func(R) lang.Either[L, R1]) lang.Either[L, R1]

FlatMap is a right biased flat map that applies the given function to the right value of the Either instance.

func FlatMapLeft

func FlatMapLeft[L, R, L1 any](e lang.Either[L, R], f func(L) lang.Either[L1, R]) lang.Either[L1, R]

FlatMapLeft is a left biased flat map that applies the given function to the left value of the Either instance.

func Flatten

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

Flatten returns the right value of the Either instance if it is right. Otherwise, it returns the right value of the inner Either instance.

func ForEach

func ForEach[L, R any](e lang.Either[L, R], f func(R))

func FromOption

func FromOption[L, R any](o lang.Option[R], l L) lang.Either[L, R]

FromOption converts an Option instance to an Either instance. If the Option instance is empty, the left value is returned. Otherwise, the right value is returned.

func Left

func Left[L, R any](le L) lang.Either[L, R]

Left returns an Either instance with the given left value.

func Map

func Map[L, R, R1 any](e lang.Either[L, R], f func(R) R1) lang.Either[L, R1]

Map is a right biased map that applies the given function to the right value of the Either instance.

func MapLeft

func MapLeft[L, R, L1 any](e lang.Either[L, R], f func(L) L1) lang.Either[L1, R]

MapLeft is a left biased map that applies the given function to the left value of the Either instance.

func OrElse

func OrElse[L, R any](e lang.Either[L, R], f func() lang.Either[L, R]) lang.Either[L, R]

OrElse returns the given Either if it is right. Otherwise, it returns the result of the given function.

func Right[L, R any](ri R) lang.Either[L, R]

Right returns an Either instance with the given right value.

func Sequence

func Sequence[L, R any](es []lang.Either[L, R]) lang.Either[L, []R]

Sequence returns an Either instance with the right value as a slice of the right values of the given Either instances. If any of the given Either instances is left, the left value is returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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