pkg

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var UnitC = &Unit{}

Functions

func Apply

func Apply[A, B any](f F1[A, B], x A) B

func EqExample

func EqExample()

func Example

func Example()

func FilterSlice

func FilterSlice[A any](f F1[A, bool], xs []A) []A

func First

func First[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 Id

func Id[A any](x A) A

func Index

func Index[T Eq[T]](s []T, e T) int

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 MapSlice

func MapSlice[A, B any](f F1[A, B], xs []A) []B

func Max

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

func Merge

func Merge[A any](xs []A, ys []A, f func(A, A) Ordering) []A

Merge needs to be rewritten iteratively TODO

func MergeSort

func MergeSort[A Ord[A]](xs []A) []A

func MergeSortWithComparator

func MergeSortWithComparator[A any](xs []A, f func(A, A) Ordering) []A

MergeSortWithComparator needs to be rewritten iteratively TODO

func Min

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

func ReduceMaybe

func ReduceMaybe[A, B any](m *Maybe[A], b B, f F2[B, A, B]) B

func ReduceSlice

func ReduceSlice[A, B any](f F2[B, A, B], b B, xs []A) B

func Replicate

func Replicate[A any](count int, item A) []A

func Second

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

Types

type Bool

type Bool bool

func (Bool) Compare

func (a Bool) Compare(b Bool) Ordering

func (Bool) Equal

func (a Bool) Equal(b Bool) bool

type Complex128

type Complex128 complex128

func (Complex128) Equal

func (a Complex128) Equal(b Complex128) bool

type Complex64

type Complex64 complex64

func (Complex64) Equal

func (a Complex64) Equal(b Complex64) bool

type Eq

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

type EqOrComparable

type EqOrComparable[A Eq[A]] interface {
	Eq[A]
	comparable
}

EqOrComparable allows us to avoid getting "invalid map key type A (missing comparable constraint)"

errors, if we just used Eq[A] without this additional interface

type F1

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

func Compose

func Compose[A, B, C any](f F1[B, C], g F1[A, B]) F1[A, C]

func Const

func Const[A, B any](x A) F1[B, A]

func Partial2

func Partial2[A, B, C any](f F2[A, B, C]) F1[A, F1[B, C]]

type F2

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

func Flip

func Flip[A, B, C any](f F2[A, B, C]) F2[B, A, C]

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 (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 (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 (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 (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 (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 (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 (Int8) Compare

func (a Int8) Compare(b Int8) Ordering

func (Int8) Equal

func (a Int8) Equal(b Int8) bool

type List

type List[A any] struct {
	Head A
	Tail *List[A] // TODO use maybe
}

func NewList

func NewList[A any](xs []A) *List[A]

type MapEq

type MapEq[A EqOrComparable[A], B Eq[B]] map[A]B

func (MapEq[A, B]) Equal

func (xs MapEq[A, B]) Equal(ys MapEq[A, B]) bool

type Maybe

type Maybe[A any] struct {
	Value *A
}

func BindMaybe

func BindMaybe[A, B any](m *Maybe[A], f F1[A, *Maybe[B]]) *Maybe[B]

func FilterMaybe

func FilterMaybe[A any](m *Maybe[A], f F1[A, bool]) *Maybe[A]

func Just

func Just[A any](a A) *Maybe[A]

func MapMaybe

func MapMaybe[A, B any](f F1[A, B], m *Maybe[A]) *Maybe[B]

func Nothing

func Nothing[A any]() *Maybe[A]

type Ord

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

type Ordering

type Ordering string

type Pair

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

func NewPair

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

type SliceEq

type SliceEq[A Eq[A]] []A

func (SliceEq[A]) Equal

func (xs SliceEq[A]) Equal(ys SliceEq[A]) bool

type SliceOrd

type SliceOrd[A Ord[A]] []A

func (SliceOrd[A]) Compare

func (xs SliceOrd[A]) Compare(ys SliceOrd[A]) Ordering

Compare should work like in Haskell. Examples from Haskell:

Prelude> [1,2,3] < [3,4,5]
True
Prelude> [1,2,3] < [3,4]
True
Prelude> [1,2,3] < []
False

func (SliceOrd[A]) Sort

func (xs SliceOrd[A]) Sort() SliceOrd[A]

type String

type 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 (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 (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 (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 (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 (Uint8) Compare

func (a Uint8) Compare(b Uint8) Ordering

func (Uint8) Equal

func (a Uint8) Equal(b Uint8) bool

type Unit

type Unit struct{}

Unit represents the Haskell value `()`

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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