nilable

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package nilable implements the Nilable type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ap

func Ap[A, B any](fab warp.Nilable[func(A) B], fa warp.Nilable[A]) warp.Nilable[B]

Ap creates a nilable by applying a function contained in the first nilable on the value contained in the second nilable if they both exist.

func ApFirst

func ApFirst[A, B any](fa warp.Nilable[A], fb warp.Nilable[B]) warp.Nilable[A]

ApFirst creates a nilable by combining two nilables, keeping only the result of the first.

func ApSecond

func ApSecond[A, B any](fa warp.Nilable[A], fb warp.Nilable[B]) warp.Nilable[B]

ApSecond creates a nilable by combining two nilables, keeping only the result of the second.

func Attempt

func Attempt[A any](f warp.IO[A]) warp.Nilable[A]

Attempt creates a nilable by running a function which returns a value, recovering with nil if a panic is thrown.

func Chain

func Chain[A, B any](ma warp.Nilable[A], f func(A) warp.Nilable[B]) warp.Nilable[B]

Chain creates a nilable which combines two nilables in sequence, using the return value of one nilable to determine the next one.

func FromPredicate

func FromPredicate[A any](a A, predicate warp.Predicate[A]) warp.Nilable[A]

FromPredicate creates a nilable by testing a value against a predicate first.

func FromResult

func FromResult[A any](ctx context.Context, ma warp.Result[A]) warp.Nilable[A]

FromResult creates a nilable from a result, returning nil for errors.

func IsNil

func IsNil[A any](a warp.Nilable[A]) bool

IsNil returns true if the value is nil.

func IsSome

func IsSome[A any](a warp.Nilable[A]) bool

IsSome returns true if the value is not nil.

func Map

func Map[A, B any](fa warp.Nilable[A], f func(A) B) warp.Nilable[B]

Map creates a nilable by applying a function on an existing value.

func Nil

func Nil[A any]() warp.Nilable[A]

Nil creates a nilable with nil value.

func Some

func Some[A any](a A) warp.Nilable[A]

Some creates a nilable with some value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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