base

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: MIT Imports: 2 Imported by: 2

Documentation

Index

Constants

View Source
const (
	OrderingLessThan    = "OrderingLessThan"
	OrderingEqual       = "OrderingEqual"
	OrderingGreaterThan = "OrderingGreaterThan"
)

Variables

View Source
var UnitC = &Unit{}

Functions

func ComparatorToCmp added in v0.2.9

func ComparatorToCmp[A any](comparator Comparator[A]) func(A, A) int

ComparatorToCmp converts a Comparator to a `cmp` function needed for using golang's package `golang.org/x/exp/slices` sort functionality cmp(a, b) should return a negative number when a < b, a positive number when a > b and zero when a == b.

func Equal

func Equal[T Eq[T]](a T, b T) bool

func EqualComparable added in v0.2.7

func EqualComparable[T comparable](a T, b T) bool

func Fst added in v0.2.0

func Fst[A, B any](p *Pair[A, B]) A

func GreaterThan

func GreaterThan[T Ord[T]](a T, b T) bool

func GreaterThanOrEqual

func GreaterThanOrEqual[T Ord[T]](a T, b T) bool

func LessThan

func LessThan[T Ord[T]](a T, b T) bool

func LessThanOrEqual

func LessThanOrEqual[T Ord[T]](a T, b T) bool

func Max

func Max[T Ord[T]](a T, b T) T

func Min

func Min[T Ord[T]](a T, b T) T

func NotEqual

func NotEqual[T Eq[T]](a T, b T) bool

func NotEqualComparable added in v0.2.7

func NotEqualComparable[T comparable](a T, b T) bool

func Snd added in v0.2.0

func Snd[A, B any](p *Pair[A, B]) B

func UnboxEq added in v0.2.7

func UnboxEq[A comparable](v *EqBox[A]) A

func UnboxEqBy added in v0.2.9

func UnboxEqBy[A any](v *EqBoxBy[A]) A

func UnboxOrd added in v0.2.7

func UnboxOrd[A constraints.Ordered](v *OrdBox[A]) A

func UnboxOrdBy added in v0.2.9

func UnboxOrdBy[A any](v *OrdBoxBy[A]) A

func UnwrapBool

func UnwrapBool(a Bool) bool

func UnwrapComplex128

func UnwrapComplex128(a Complex128) complex128

func UnwrapComplex64

func UnwrapComplex64(a Complex64) complex64

func UnwrapFloat32

func UnwrapFloat32(a Float32) float32

func UnwrapFloat64

func UnwrapFloat64(a Float64) float64

func UnwrapInt

func UnwrapInt(a Int) int

func UnwrapInt16

func UnwrapInt16(a Int16) int16

func UnwrapInt32

func UnwrapInt32(a Int32) int32

func UnwrapInt64

func UnwrapInt64(a Int64) int64

func UnwrapInt8

func UnwrapInt8(a Int8) int8

func UnwrapString

func UnwrapString(a String) string

func UnwrapUint

func UnwrapUint(a Uint) uint

func UnwrapUint16

func UnwrapUint16(a Uint16) uint16

func UnwrapUint32

func UnwrapUint32(a Uint32) uint32

func UnwrapUint64

func UnwrapUint64(a Uint64) uint64

func UnwrapUint8

func UnwrapUint8(a Uint8) uint8

func UnwrapUintptr

func UnwrapUintptr(a Uintptr) uintptr

Types

type Bool

type Bool bool

func WrapBool

func WrapBool(a bool) Bool

func (Bool) Compare

func (a Bool) Compare(b Bool) Ordering

func (Bool) Equal

func (a Bool) Equal(b Bool) bool

type Comparator

type Comparator[A any] func(A, A) Ordering

func CompareOn added in v0.2.7

func CompareOn[A any, B constraints.Ordered](on func(A) B) Comparator[A]

func CompareOnBy added in v0.3.1

func CompareOnBy[A any, B any](on func(A) B, by Comparator[B]) Comparator[A]

func CompareOnOrd added in v0.2.4

func CompareOnOrd[A any, B Ord[B]](on func(A) B) Comparator[A]

func ComparePair added in v0.2.7

func ComparePair[A constraints.Ordered, B constraints.Ordered]() Comparator[*Pair[A, B]]

func ComparePairBy added in v0.2.7

func ComparePairBy[A, B any](fst Comparator[A], snd Comparator[B]) Comparator[*Pair[A, B]]

func ComparePairOrd added in v0.2.7

func ComparePairOrd[A Ord[A], B Ord[B]]() Comparator[*Pair[A, B]]

func CompareReverse added in v0.2.4

func CompareReverse[A any](compare Comparator[A]) Comparator[A]

func ConstComparator added in v0.1.1

func ConstComparator[T any](a Ordering) Comparator[T]

type Complex128

type Complex128 complex128

func WrapComplex128

func WrapComplex128(a complex128) Complex128

func (Complex128) Equal

func (a Complex128) Equal(b Complex128) bool

type Complex64

type Complex64 complex64

func WrapComplex64

func WrapComplex64(a complex64) Complex64

func (Complex64) Equal

func (a Complex64) Equal(b Complex64) bool

type Eq

type Eq[T any] interface {
	Equal(T) bool
}

type EqBox added in v0.2.7

type EqBox[A comparable] struct {
	Value A
}

EqBox allows any comparable to be used as an Eq

func BoxEq added in v0.2.7

func BoxEq[A comparable](a A) *EqBox[A]

func (*EqBox[A]) Equal added in v0.2.7

func (e *EqBox[A]) Equal(other *EqBox[A]) bool

type EqBoxBy added in v0.2.9

type EqBoxBy[A any] struct {
	Value A
	Eq    Equaler[A]
}

EqBoxBy allows any type to be used as an Eq

func BoxEqBy added in v0.2.9

func BoxEqBy[A any](a A, eq Equaler[A]) *EqBoxBy[A]

func (*EqBoxBy[A]) Equal added in v0.2.9

func (e *EqBoxBy[A]) Equal(other *EqBoxBy[A]) bool

type Equaler

type Equaler[A any] func(A, A) bool

func EqualOn added in v0.3.0

func EqualOn[A any, B comparable](on func(A) B) Equaler[A]

func EqualOnBy added in v0.3.1

func EqualOnBy[A any, B any](on func(A) B, by Equaler[B]) Equaler[A]

func EqualOnEq added in v0.3.0

func EqualOnEq[A any, B Eq[B]](on func(A) B) Equaler[A]

func EqualPair added in v0.2.7

func EqualPair[A comparable, B comparable]() Equaler[*Pair[A, B]]

func EqualPairBy added in v0.2.7

func EqualPairBy[A, B any](fst Equaler[A], snd Equaler[B]) Equaler[*Pair[A, B]]

func EqualPairEq added in v0.2.7

func EqualPairEq[A Eq[A], B Eq[B]]() Equaler[*Pair[A, B]]

type F1

type F1[A, Z any] func(A) Z

type F2

type F2[A, B, Z any] func(A, B) Z

type F3

type F3[A, B, C, Z any] func(A, B, C) Z

type F4

type F4[A, B, C, D, Z any] func(A, B, C, D) Z

type F5

type F5[A, B, C, D, E, Z any] func(A, B, C, D, E) Z

type Float32

type Float32 float32

func WrapFloat32

func WrapFloat32(a float32) Float32

func (Float32) Compare

func (a Float32) Compare(b Float32) Ordering

func (Float32) Equal

func (a Float32) Equal(b Float32) bool

type Float64

type Float64 float64

func WrapFloat64

func WrapFloat64(a float64) Float64

func (Float64) Compare

func (a Float64) Compare(b Float64) Ordering

func (Float64) Equal

func (a Float64) Equal(b Float64) bool

type Int

type Int int

func WrapInt

func WrapInt(a int) Int

func (Int) Compare

func (a Int) Compare(b Int) Ordering

func (Int) Equal

func (a Int) Equal(b Int) bool

type Int16

type Int16 int16

func WrapInt16

func WrapInt16(a int16) Int16

func (Int16) Compare

func (a Int16) Compare(b Int16) Ordering

func (Int16) Equal

func (a Int16) Equal(b Int16) bool

type Int32

type Int32 int32

func WrapInt32

func WrapInt32(a int32) Int32

func (Int32) Compare

func (a Int32) Compare(b Int32) Ordering

func (Int32) Equal

func (a Int32) Equal(b Int32) bool

type Int64

type Int64 int64

func WrapInt64

func WrapInt64(a int64) Int64

func (Int64) Compare

func (a Int64) Compare(b Int64) Ordering

func (Int64) Equal

func (a Int64) Equal(b Int64) bool

type Int8

type Int8 int8

func WrapInt8

func WrapInt8(a int8) Int8

func (Int8) Compare

func (a Int8) Compare(b Int8) Ordering

func (Int8) Equal

func (a Int8) Equal(b Int8) bool

type Ord

type Ord[T any] interface {
	Eq[T]
	Compare(T) Ordering
}

type OrdBox added in v0.2.7

type OrdBox[A constraints.Ordered] struct {
	Value A
}

OrdBox allows any constraints.Ordered to be used as an Ord

func BoxOrd added in v0.2.7

func BoxOrd[A constraints.Ordered](a A) *OrdBox[A]

func (*OrdBox[A]) Compare added in v0.2.7

func (o *OrdBox[A]) Compare(other *OrdBox[A]) Ordering

func (*OrdBox[A]) Equal added in v0.2.7

func (o *OrdBox[A]) Equal(other *OrdBox[A]) bool

type OrdBoxBy added in v0.2.9

type OrdBoxBy[A any] struct {
	Value A
	Eq    Equaler[A]
	Ord   Comparator[A]
}

OrdBoxBy allows any type to be used as an Ord. Note that since each value carries its own Equaler and Comparator, you'll get weird results if you mix OrdBoxBys which have different Equalers or Comparators. So don't do this.

func BoxOrdBy added in v0.2.9

func BoxOrdBy[A any](a A, eq Equaler[A], ord Comparator[A]) *OrdBoxBy[A]

func (*OrdBoxBy[A]) Compare added in v0.2.9

func (o *OrdBoxBy[A]) Compare(other *OrdBoxBy[A]) Ordering

func (*OrdBoxBy[A]) Equal added in v0.2.9

func (o *OrdBoxBy[A]) Equal(other *OrdBoxBy[A]) bool

type Ordering

type Ordering string

func Compare

func Compare[A Ord[A]](x A, y A) Ordering

func CompareBool added in v0.2.7

func CompareBool(a bool, b bool) Ordering

func CompareOrdered added in v0.2.7

func CompareOrdered[A constraints.Ordered](a A, b A) Ordering

func FlipOrdering

func FlipOrdering(a Ordering) Ordering

func (Ordering) Compare

func (a Ordering) Compare(b Ordering) Ordering

func (Ordering) Equal

func (a Ordering) Equal(b Ordering) bool

func (Ordering) Flip added in v0.1.1

func (a Ordering) Flip() Ordering

type Pair

type Pair[A, B any] struct {
	Fst A
	Snd B
}

func NewPair

func NewPair[A, B any](a A, b B) *Pair[A, B]

type String

type String string

func WrapString

func WrapString(a string) String

func (String) Compare

func (a String) Compare(b String) Ordering

func (String) Equal

func (a String) Equal(b String) bool

type Uint

type Uint uint

func WrapUint

func WrapUint(a uint) Uint

func (Uint) Compare

func (a Uint) Compare(b Uint) Ordering

func (Uint) Equal

func (a Uint) Equal(b Uint) bool

type Uint16

type Uint16 uint16

func WrapUint16

func WrapUint16(a uint16) Uint16

func (Uint16) Compare

func (a Uint16) Compare(b Uint16) Ordering

func (Uint16) Equal

func (a Uint16) Equal(b Uint16) bool

type Uint32

type Uint32 uint32

func WrapUint32

func WrapUint32(a uint32) Uint32

func (Uint32) Compare

func (a Uint32) Compare(b Uint32) Ordering

func (Uint32) Equal

func (a Uint32) Equal(b Uint32) bool

type Uint64

type Uint64 uint64

func WrapUint64

func WrapUint64(a uint64) Uint64

func (Uint64) Compare

func (a Uint64) Compare(b Uint64) Ordering

func (Uint64) Equal

func (a Uint64) Equal(b Uint64) bool

type Uint8

type Uint8 uint8

func WrapUint8

func WrapUint8(a uint8) Uint8

func (Uint8) Compare

func (a Uint8) Compare(b Uint8) Ordering

func (Uint8) Equal

func (a Uint8) Equal(b Uint8) bool

type Uintptr

type Uintptr uintptr

func WrapUintptr

func WrapUintptr(a uintptr) Uintptr

func (Uintptr) Compare

func (a Uintptr) Compare(b Uintptr) Ordering

func (Uintptr) Equal

func (a Uintptr) Equal(b Uintptr) bool

type Unit added in v0.2.2

type Unit struct{}

Unit represents the Haskell value `()`

func (*Unit) Compare added in v0.2.7

func (u *Unit) Compare(other *Unit) Ordering

func (*Unit) Equal added in v0.2.7

func (u *Unit) Equal(other *Unit) bool

Jump to

Keyboard shortcuts

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