monad

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2025 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error[T any] struct {
	Err error
}

func (Error[T]) DoIf added in v0.0.14

func (err Error[T]) DoIf(op.Operator[T], func(T) Result[T]) Result[T]

func (Error[T]) DoIfError added in v0.0.14

func (err Error[T]) DoIfError(operator op.Operator[error], do func(error) Result[T]) Result[T]

func (Error[T]) Error

func (err Error[T]) Error(call func(error) Result[T]) Result[T]

func (Error[T]) If added in v0.0.14

func (err Error[T]) If(op.Operator[T]) bool

func (Error[T]) IfError added in v0.0.14

func (err Error[T]) IfError(operator op.Operator[error]) bool

func (Error[T]) Or

func (err Error[T]) Or(value T) Result[T]

func (Error[T]) String

func (err Error[T]) String() string

func (Error[T]) Then

func (err Error[T]) Then(func(T) Result[T]) Result[T]

func (Error[T]) TryError

func (err Error[T]) TryError() error

func (Error[T]) TryValue

func (err Error[T]) TryValue() T

func (Error[T]) WhenError

func (err Error[T]) WhenError(call func(error)) Result[T]

func (Error[T]) WhenOK

func (err Error[T]) WhenOK(func(T)) Result[T]

type Maybe

type Maybe[T any] interface {
	Then(call func(T) Maybe[T]) Maybe[T]
	Else(call func() Maybe[T]) Maybe[T]
	WhenValue(call func(T)) Maybe[T]
	WhenNothing(call func()) Maybe[T]
	Or(value T) Maybe[T]
	If(comparator op.Operator[T]) bool
	DoIf(comparator op.Operator[T], do func(T) Maybe[T]) Maybe[T]
	TryValue() T
	// contains filtered or unexported methods
}

func NewMaybe

func NewMaybe[T any](value *T) Maybe[T]

type MaybeIsNothingError

type MaybeIsNothingError struct {
	// contains filtered or unexported fields
}

func NewMaybeIsNothingError

func NewMaybeIsNothingError() MaybeIsNothingError

type Nothing

type Nothing[T any] struct{}

func (Nothing[T]) DoIf added in v0.0.14

func (nothing Nothing[T]) DoIf(op.Operator[T], func(T) Maybe[T]) Maybe[T]

func (Nothing[T]) Else

func (nothing Nothing[T]) Else(call func() Maybe[T]) Maybe[T]

func (Nothing[T]) If added in v0.0.14

func (nothing Nothing[T]) If(op.Operator[T]) bool

func (Nothing[T]) Or

func (nothing Nothing[T]) Or(value T) Maybe[T]

func (Nothing[T]) String

func (Nothing[T]) String() string

func (Nothing[T]) Then

func (nothing Nothing[T]) Then(func(T) Maybe[T]) Maybe[T]

func (Nothing[T]) TryValue

func (Nothing[T]) TryValue() T

func (Nothing[T]) WhenNothing

func (nothing Nothing[T]) WhenNothing(call func()) Maybe[T]

func (Nothing[T]) WhenValue

func (nothing Nothing[T]) WhenValue(func(T)) Maybe[T]

type OK

type OK[T any] struct {
	Value T
}

func (OK[T]) DoIf added in v0.0.14

func (ok OK[T]) DoIf(comparator op.Operator[T], do func(T) Result[T]) Result[T]

func (OK[T]) DoIfError added in v0.0.14

func (ok OK[T]) DoIfError(op.Operator[error], func(error) Result[T]) Result[T]

func (OK[T]) Error

func (ok OK[T]) Error(func(error) Result[T]) Result[T]

func (OK[T]) If added in v0.0.14

func (ok OK[T]) If(operator op.Operator[T]) bool

func (OK[T]) IfError added in v0.0.14

func (ok OK[T]) IfError(op.Operator[error]) bool

func (OK[T]) Or

func (ok OK[T]) Or(T) Result[T]

func (OK[T]) String

func (ok OK[T]) String() string

func (OK[T]) Then

func (ok OK[T]) Then(call func(T) Result[T]) Result[T]

func (OK[T]) TryError

func (ok OK[T]) TryError() error

func (OK[T]) TryValue

func (ok OK[T]) TryValue() T

func (OK[T]) WhenError

func (ok OK[T]) WhenError(func(error)) Result[T]

func (OK[T]) WhenOK

func (ok OK[T]) WhenOK(call func(T)) Result[T]

type Result

type Result[T any] interface {
	Then(call func(T) Result[T]) Result[T]
	Error(call func(error) Result[T]) Result[T]
	WhenOK(call func(T)) Result[T]
	WhenError(call func(error)) Result[T]
	Or(value T) Result[T]
	If(operator op.Operator[T]) bool
	DoIf(comparator op.Operator[T], do func(T) Result[T]) Result[T]
	IfError(operator op.Operator[error]) bool
	DoIfError(operator op.Operator[error], do func(error) Result[T]) Result[T]
	TryValue() T
	TryError() error
	// contains filtered or unexported methods
}

type ResultIsErrorError

type ResultIsErrorError struct {
	Err error
	// contains filtered or unexported fields
}

func NewResultIsErrorError

func NewResultIsErrorError(err error) ResultIsErrorError

type ResultIsOkError

type ResultIsOkError struct {
	// contains filtered or unexported fields
}

func NewResultIsOkError

func NewResultIsOkError() ResultIsOkError

type Some

type Some[T any] struct {
	Value T
}

func (Some[T]) DoIf added in v0.0.14

func (some Some[T]) DoIf(comparator op.Operator[T], do func(T) Maybe[T]) Maybe[T]

func (Some[T]) Else

func (some Some[T]) Else(func() Maybe[T]) Maybe[T]

func (Some[T]) If added in v0.0.14

func (some Some[T]) If(comparator op.Operator[T]) bool

func (Some[T]) Or

func (some Some[T]) Or(T) Maybe[T]

func (Some[T]) String

func (some Some[T]) String() string

func (Some[T]) Then

func (some Some[T]) Then(call func(T) Maybe[T]) Maybe[T]

func (Some[T]) TryValue

func (some Some[T]) TryValue() T

func (Some[T]) WhenNothing

func (some Some[T]) WhenNothing(func()) Maybe[T]

func (Some[T]) WhenValue

func (some Some[T]) WhenValue(call func(T)) Maybe[T]

Jump to

Keyboard shortcuts

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