fn

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 2 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BiConsumer

type BiConsumer[T any, U any] interface {
	Accept(T, U)
	CheckedAccept(T, U) error
}

func BiConsumerCast

func BiConsumerCast[T any, U any](fn func(T, U) error) BiConsumer[T, U]

func BiConsumerOf

func BiConsumerOf[T any, U any](fn func(T, U)) BiConsumer[T, U]

type BiConsumerCheckedFn

type BiConsumerCheckedFn[T any, U any] func(T, U) error

func (BiConsumerCheckedFn[T, U]) Accept

func (fn BiConsumerCheckedFn[T, U]) Accept(t T, u U)

func (BiConsumerCheckedFn[T, U]) CheckedAccept

func (fn BiConsumerCheckedFn[T, U]) CheckedAccept(t T, u U) error

type BiConsumerFn

type BiConsumerFn[T any, U any] func(T, U)

func (BiConsumerFn[T, U]) Accept

func (fn BiConsumerFn[T, U]) Accept(t T, u U)

func (BiConsumerFn[T, U]) CheckedAccept

func (fn BiConsumerFn[T, U]) CheckedAccept(t T, u U) error

type BiFunction

type BiFunction[T any, U any, R any] interface {
	Apply(T, U) R
	CheckedApply(T, U) (R, error)
	Curry() func(T) Function[U, R]
	Partial(T) Function[U, R]
}

func BiFunctionCast

func BiFunctionCast[T any, U any, R any](fn func(T, U) (R, error)) BiFunction[T, U, R]

func BiFunctionOf

func BiFunctionOf[T any, U any, R any](fn func(T, U) R) BiFunction[T, U, R]

type BiFunctionCheckedFn

type BiFunctionCheckedFn[T any, U any, R any] func(T, U) (R, error)

func (BiFunctionCheckedFn[T, U, R]) Apply

func (fn BiFunctionCheckedFn[T, U, R]) Apply(t T, u U) R

func (BiFunctionCheckedFn[T, U, R]) CheckedApply

func (fn BiFunctionCheckedFn[T, U, R]) CheckedApply(t T, u U) (R, error)

func (BiFunctionCheckedFn[T, U, R]) Curry

func (fn BiFunctionCheckedFn[T, U, R]) Curry() func(T) Function[U, R]

func (BiFunctionCheckedFn[T, U, R]) Partial

func (fn BiFunctionCheckedFn[T, U, R]) Partial(t T) Function[U, R]

type BiFunctionFn

type BiFunctionFn[T any, U any, R any] func(T, U) R

func (BiFunctionFn[T, U, R]) Apply

func (fn BiFunctionFn[T, U, R]) Apply(t T, u U) R

func (BiFunctionFn[T, U, R]) CheckedApply

func (fn BiFunctionFn[T, U, R]) CheckedApply(t T, u U) (R, error)

func (BiFunctionFn[T, U, R]) Curry

func (fn BiFunctionFn[T, U, R]) Curry() func(T) Function[U, R]

func (BiFunctionFn[T, U, R]) Partial

func (fn BiFunctionFn[T, U, R]) Partial(t T) Function[U, R]

type Consumer

type Consumer[T any] interface {
	Accept(T)
	CheckedAccept(T) error
}

func CheckZeroAccept

func CheckZeroAccept[T any](
	zeroFn Runnable,
	notZeroFn Consumer[T]) Consumer[T]

func ConsumerCast

func ConsumerCast[T any](fn func(T) error) Consumer[T]

func ConsumerChan

func ConsumerChan[T any](ch chan T) Consumer[T]

func ConsumerOf

func ConsumerOf[T any](fn func(T)) Consumer[T]

func Ignore

func Ignore[T any]() Consumer[T]

func IsZeroThenRun

func IsZeroThenRun[T any](zeroFn Runnable) Consumer[T]

func JoinConsumers added in v0.2.0

func JoinConsumers[T any](consumers ...Consumer[T]) Consumer[T]

func MustAccept added in v0.4.0

func MustAccept[T any](consumer Consumer[T]) Consumer[T]

func NotZeroThenAccept

func NotZeroThenAccept[T any](notZeroFn Consumer[T]) Consumer[T]

type ConsumerCh

type ConsumerCh[T any] chan<- T

func (ConsumerCh[T]) Accept

func (ch ConsumerCh[T]) Accept(t T)

func (ConsumerCh[T]) CheckedAccept

func (ch ConsumerCh[T]) CheckedAccept(t T) error

type ConsumerCheckedFn

type ConsumerCheckedFn[T any] func(T) error

func (ConsumerCheckedFn[T]) Accept

func (fn ConsumerCheckedFn[T]) Accept(t T)

func (ConsumerCheckedFn[T]) CheckedAccept

func (fn ConsumerCheckedFn[T]) CheckedAccept(t T) error

type ConsumerFn

type ConsumerFn[T any] func(T)

func (ConsumerFn[T]) Accept

func (fn ConsumerFn[T]) Accept(t T)

func (ConsumerFn[T]) CheckedAccept

func (fn ConsumerFn[T]) CheckedAccept(t T) error

type Consumers added in v0.2.0

type Consumers[T any] []Consumer[T]

func (Consumers[T]) Accept added in v0.2.0

func (s Consumers[T]) Accept(t T)

func (Consumers[T]) CheckedAccept added in v0.2.0

func (s Consumers[T]) CheckedAccept(t T) error

type Function

type Function[T any, R any] interface {
	Apply(T) R
	CheckedApply(T) (R, error)
}

func CheckZeroApply

func CheckZeroApply[T any, R any](
	zeroFn Supplier[R],
	notZeroFn Function[T, R]) Function[T, R]

func ComposeFunction added in v0.4.0

func ComposeFunction[T any, R any, V any](before Function[T, R], after Function[R, V]) Function[T, V]

func FunctionCast

func FunctionCast[T any, R any](fn func(T) (R, error)) Function[T, R]

func FunctionOf

func FunctionOf[T any, R any](fn func(T) R) Function[T, R]

func Identity

func Identity[T any]() Function[T, T]

func IsZeroThenGet

func IsZeroThenGet[T any](
	zeroFn Supplier[T]) Function[T, T]

func MustApply added in v0.4.0

func MustApply[T any, R any](function Function[T, R]) Function[T, R]

func NotZeroThenApply

func NotZeroThenApply[T any, R any](
	notZeroFn Function[T, R]) Function[T, R]

func YCombinator

func YCombinator[T any](f func(func(T) T) func(T) T) Function[T, T]

type FunctionCheckedFn

type FunctionCheckedFn[T any, R any] func(T) (R, error)

func (FunctionCheckedFn[T, R]) Apply

func (fn FunctionCheckedFn[T, R]) Apply(t T) R

func (FunctionCheckedFn[T, R]) CheckedApply

func (fn FunctionCheckedFn[T, R]) CheckedApply(t T) (R, error)

type FunctionComposed added in v0.4.0

type FunctionComposed[T any, R any, V any] struct {
	// contains filtered or unexported fields
}

func (FunctionComposed[T, R, V]) Apply added in v0.4.0

func (fn FunctionComposed[T, R, V]) Apply(t T) V

func (FunctionComposed[T, R, V]) CheckedApply added in v0.4.0

func (fn FunctionComposed[T, R, V]) CheckedApply(t T) (V, error)

type FunctionFn

type FunctionFn[T any, R any] func(T) R

func (FunctionFn[T, R]) Apply

func (fn FunctionFn[T, R]) Apply(t T) R

func (FunctionFn[T, R]) CheckedApply

func (fn FunctionFn[T, R]) CheckedApply(t T) (R, error)

type Runnable

type Runnable interface {
	Run()
	CheckedRun() error
}

func Empty

func Empty() Runnable

func MustRun added in v0.4.0

func MustRun(runnable Runnable) Runnable

func RunnableCast

func RunnableCast(fn func() error) Runnable

func RunnableOf

func RunnableOf(fn func()) Runnable

type RunnableCheckedFn

type RunnableCheckedFn func() error

func (RunnableCheckedFn) CheckedRun

func (fn RunnableCheckedFn) CheckedRun() error

func (RunnableCheckedFn) Run

func (fn RunnableCheckedFn) Run()

type RunnableFn

type RunnableFn func()

func (RunnableFn) CheckedRun

func (fn RunnableFn) CheckedRun() error

func (RunnableFn) Run

func (fn RunnableFn) Run()

type Supplier

type Supplier[T any] interface {
	Get() T
	CheckedGet() (T, error)
}

func Constant

func Constant[T any](t T) Supplier[T]

func MustGet added in v0.4.0

func MustGet[T any](supplier Supplier[T]) Supplier[T]

func SupplierCast

func SupplierCast[T any](fn func() (T, error)) Supplier[T]

func SupplierOf

func SupplierOf[T any](fn func() T) Supplier[T]

func Zero

func Zero[T any]() Supplier[T]

type SupplierCheckedFn

type SupplierCheckedFn[T any] func() (T, error)

func (SupplierCheckedFn[T]) CheckedGet

func (fn SupplierCheckedFn[T]) CheckedGet() (T, error)

func (SupplierCheckedFn[T]) Get

func (fn SupplierCheckedFn[T]) Get() T

type SupplierFn

type SupplierFn[T any] func() T

func (SupplierFn[T]) CheckedGet

func (fn SupplierFn[T]) CheckedGet() (T, error)

func (SupplierFn[T]) Get

func (fn SupplierFn[T]) Get() T

Jump to

Keyboard shortcuts

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