Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Maybe ¶
type Maybe[T any] struct { // contains filtered or unexported fields }
Maybe T = Some T | Nothing. A data wrapper that allows values to be something [Some T] or nothing Nothing. Invariant: If [hasValue] is false, then [value] is the zero value of type T. Maybe is used to wrap types: * That can't be represented by nil. * That use nil as a valid value instead of an indicator of a missing value. For more info see https://en.wikipedia.org/wiki/Option_type
func Bind ¶
Bind returns Nothing iff [m] is Nothing. Otherwise applies [f] to the value of [m] and returns the result as a Some.
func Some ¶
Some returns a new Maybe[T] with the value val. If m.IsNothing(), returns the zero value of type T.
Click to show internal directories.
Click to hide internal directories.