fu

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 3 Imported by: 0

README

Funky Go - FU

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add[T Number](v T) func(T) T

func C

func C[T any](values ...T) chan T

func Construct added in v0.0.2

func Construct[T any](options ...Option[T]) *T

func Decrement

func Decrement[T Number]() func(T) T

func Divide

func Divide[T Number](v T) func(T) T

func Eq

func Eq[T Number](v T) func(T) bool

func Gt

func Gt[T Number](v T) func(T) bool

func Gte

func Gte[T Number](v T) func(T) bool

func Increment

func Increment[T Number]() func(T) T

func Lt

func Lt[T Number](v T) func(T) bool

func Lte

func Lte[T Number](v T) func(T) bool

func Map2Struct

func Map2Struct[T any](data map[string]any, into T) (T, error)

func Memoize

func Memoize[T any](f func() T) func() T

func MemoizeWithError

func MemoizeWithError[T any](f func() (T, error)) func() (T, error)

func Mod

func Mod[T constraints.Integer](v T) func(T) T

func Multiply

func Multiply[T Number](v T) func(T) T

func Ne

func Ne[T Number](v T) func(T) bool

func Safe added in v0.0.2

func Safe[T any](f func(T)) func(T) error

func Subtract added in v0.0.2

func Subtract[T Number](v T) func(T) T

func With added in v0.0.3

func With[T any](value *T, options ...Option[T])

func Zero

func Zero[T any]() T

Types

type CanError

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

type Either

type Either[L, R any] func() (L, R, LeftOrRight)

func Left

func Left[L, R any](left L) Either[L, R]
func Right[L, R any](right R) Either[L, R]

type LeftOrRight

type LeftOrRight bool
const (
	IsLeft  LeftOrRight = false
	IsRight LeftOrRight = true
)

type Number

type Number interface {
	constraints.Integer | constraints.Float
}

type Option added in v0.0.2

type Option[T any] func(*T)

type OptionalValue

type OptionalValue[T any] func() (*T, bool)

func Optional

func Optional[T any](value *T) OptionalValue[T]

func OptionalP

func OptionalP[T any](value Pointer[T]) OptionalValue[T]

func (OptionalValue[T]) Do

func (o OptionalValue[T]) Do(with func(*T))

func (OptionalValue[T]) Exists

func (o OptionalValue[T]) Exists() bool

func (OptionalValue[T]) Or

func (o OptionalValue[T]) Or(fill func() *T) OptionalValue[T]

type Pointer

type Pointer[T any] func() *T

func Nil

func Nil[T any]() Pointer[T]

func Ptr

func Ptr[T any](value T) Pointer[T]

type Set

type Set[T comparable] map[T]struct{}

func (Set[T]) Add

func (set Set[T]) Add(value T) Set[T]

func (Set[T]) Contains

func (set Set[T]) Contains(value T) bool

func (Set[T]) ContainsAll

func (set Set[T]) ContainsAll(values ...T) bool

func (Set[T]) ContainsNone

func (set Set[T]) ContainsNone(values ...T) bool

type ValueOrError

type ValueOrError[T any] Either[T, error]

func Try

func Try[T any](f CanError[T]) ValueOrError[T]

func (ValueOrError[T]) OnError

func (v ValueOrError[T]) OnError(f func(error)) ValueOrError[T]

func (ValueOrError[T]) OnSuccess

func (v ValueOrError[T]) OnSuccess(f func(T)) ValueOrError[T]

func (ValueOrError[T]) Return

func (v ValueOrError[T]) Return() (T, error)

Jump to

Keyboard shortcuts

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