eq

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Comparable added in v0.0.2

func Comparable[A comparable](x, y A) bool

Comparable implements EqualFn for natively comparable types.

func Conform

func Conform[A any, CA Class[A]](c CA) func(t *testing.T, x, y, z A)

Conform returns a function testing if the implementation abides by its laws.

Types

type Class

type Class[A any] interface {
	Equal(A, A) bool
	NE(A, A) bool
}

type EqualFn added in v0.0.2

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

type Type added in v0.0.2

type Type[A any] struct {
	// contains filtered or unexported fields
}

func NewType added in v0.0.2

func NewType[A any](equalFn EqualFn[A]) Type[A]
Example
package main

import (
	"fmt"

	"github.com/calebcase/base/data/eq"
)

func main() {
	t := eq.NewType(eq.Comparable[int])

	fmt.Println(t.Equal(1, 1))
	fmt.Println(t.NE(1, 2))

}
Output:

true
true

func (Type[A]) Equal added in v0.0.2

func (t Type[A]) Equal(x, y A) bool

func (Type[A]) NE added in v0.0.2

func (t Type[A]) NE(x, y A) bool

Jump to

Keyboard shortcuts

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