either

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fold

func Fold[A any, B any, C any](eab Either[A, B], left func(A) C, right func(B) C) C

Fold pattern matches Either with two given pattern match handlers

func GetLeft

func GetLeft[A any, B any](eab Either[A, B]) option.Option[A]

GetLeft returns left if it's defined.

func GetRight

func GetRight[A any, B any](eab Either[A, B]) option.Option[B]

GetRight returns left if it's defined.

func IsLeft

func IsLeft[A any, B any](eab Either[A, B]) bool

IsLeft checks whether the provided Either is left or not.

func IsRight

func IsRight[A any, B any](eab Either[A, B]) bool

IsRight checks whether the provided Either is right or not.

Types

type Either

type Either[A any, B any] struct {
	IsLeft bool
	Left   A
	Right  B
}

Either is a simple data structure that can have either left value or right value.

func Left

func Left[A any, B any](a A) Either[A, B]

Left constructs Either that is left.

func Right[A any, B any](b B) Either[A, B]

Right constructs Either that is right.

Jump to

Keyboard shortcuts

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