Help us shape the future of Go! Take the 2026 Go Developer Survey

pair

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ap

func Ap[B, A, A1 any](sg Sg.Semigroup[B], fa Pair[A, B]) func(Pair[func(A) A1, B]) Pair[A1, B]

Ap applies on the head value

func ApHead

func ApHead[B, A, A1 any](sg Sg.Semigroup[B], fa Pair[A, B]) func(Pair[func(A) A1, B]) Pair[A1, B]

ApHead applies on the head value

func ApTail

func ApTail[A, B, B1 any](sg Sg.Semigroup[A], fb Pair[A, B]) func(Pair[A, func(B) B1]) Pair[A, B1]

ApTail applies on the Tail value

func Applicative

func Applicative[A, B, A1 any](m M.Monoid[B]) applicative.Applicative[A, A1, Pair[A, B], Pair[A1, B], Pair[func(A) A1, B]]

Applicative implements the applicative operations for Pair

func ApplicativeHead

func ApplicativeHead[A, B, A1 any](m M.Monoid[B]) applicative.Applicative[A, A1, Pair[A, B], Pair[A1, B], Pair[func(A) A1, B]]

ApplicativeHead implements the applicative operations for Pair

func ApplicativeTail

func ApplicativeTail[B, A, B1 any](m M.Monoid[A]) applicative.Applicative[B, B1, Pair[A, B], Pair[A, B1], Pair[A, func(B) B1]]

ApplicativeTail implements the applicative operations for Pair

func BiMap

func BiMap[A, B, A1, B1 any](f func(A) A1, g func(B) B1) func(Pair[A, B]) Pair[A1, B1]

BiMap maps both values

func Chain

func Chain[B, A, A1 any](sg Sg.Semigroup[B], f func(A) Pair[A1, B]) func(Pair[A, B]) Pair[A1, B]

Chain chains on the head value

func ChainHead

func ChainHead[B, A, A1 any](sg Sg.Semigroup[B], f func(A) Pair[A1, B]) func(Pair[A, B]) Pair[A1, B]

ChainHead chains on the head value

func ChainTail

func ChainTail[A, B, B1 any](sg Sg.Semigroup[A], f func(B) Pair[A, B1]) func(Pair[A, B]) Pair[A, B1]

ChainTail chains on the Tail value

func Eq

func Eq[A, B any](a EQ.Eq[A], b EQ.Eq[B]) EQ.Eq[Pair[A, B]]

Constructs an equal predicate for an `Either`

func FromStrictEquals

func FromStrictEquals[A, B comparable]() EQ.Eq[Pair[A, B]]

FromStrictEquals constructs an [EQ.Eq] from the canonical comparison function

func Functor

func Functor[A, B, A1 any]() functor.Functor[A, A1, Pair[A, B], Pair[A1, B]]

Functor implements the functor operations for Pair

func FunctorHead

func FunctorHead[A, B, A1 any]() functor.Functor[A, A1, Pair[A, B], Pair[A1, B]]

FunctorHead implements the functor operations for Pair

func FunctorTail

func FunctorTail[B, A, B1 any]() functor.Functor[B, B1, Pair[A, B], Pair[A, B1]]

FunctorTail implements the functor operations for Pair

func Head[A, B any](fa Pair[A, B]) A

Head returns the head value of the pair

func Map

func Map[B, A, A1 any](f func(A) A1) func(Pair[A, B]) Pair[A1, B]

Map maps the head value

func MapHead

func MapHead[B, A, A1 any](f func(A) A1) func(Pair[A, B]) Pair[A1, B]

MapHead maps the head value

func MapTail

func MapTail[A, B, B1 any](f func(B) B1) func(Pair[A, B]) Pair[A, B1]

MapTail maps the Tail value

func Merge added in v1.0.128

func Merge[F ~func(B) func(A) R, A, B, R any](f F) func(Pair[A, B]) R

func Monad

func Monad[A, B, A1 any](m M.Monoid[B]) monad.Monad[A, A1, Pair[A, B], Pair[A1, B], Pair[func(A) A1, B]]

Monad implements the monadic operations for Pair

func MonadHead

func MonadHead[A, B, A1 any](m M.Monoid[B]) monad.Monad[A, A1, Pair[A, B], Pair[A1, B], Pair[func(A) A1, B]]

MonadHead implements the monadic operations for Pair

func MonadTail

func MonadTail[B, A, B1 any](m M.Monoid[A]) monad.Monad[B, B1, Pair[A, B], Pair[A, B1], Pair[A, func(B) B1]]

MonadTail implements the monadic operations for Pair

func Paired added in v1.0.128

func Paired[F ~func(T1, T2) R, T1, T2, R any](f F) func(Pair[T1, T2]) R

Paired converts a function with 2 parameters into a function taking a Pair The inverse function is Unpaired

func Pointed

func Pointed[A, B any](m M.Monoid[B]) pointed.Pointed[A, Pair[A, B]]

Pointed implements the pointed operations for Pair

func PointedHead

func PointedHead[A, B any](m M.Monoid[B]) pointed.Pointed[A, Pair[A, B]]

PointedHead implements the pointed operations for Pair

func PointedTail

func PointedTail[B, A any](m M.Monoid[A]) pointed.Pointed[B, Pair[A, B]]

PointedTail implements the pointed operations for Pair

func Tail

func Tail[A, B any](fa Pair[A, B]) B

Tail returns the head value of the pair

func ToTuple

func ToTuple[A, B any](t Pair[A, B]) T.Tuple2[A, B]

ToTuple creates a [T.Tuple2] from a Pair

func Unpaired added in v1.0.128

func Unpaired[F ~func(Pair[T1, T2]) R, T1, T2, R any](f F) func(T1, T2) R

Unpaired converts a function with a Pair parameter into a function with 2 parameters The inverse function is Paired

Types

type Pair

type Pair[A, B any] pair

Pair defines a data structure that holds two strongly typed values

func FromTuple

func FromTuple[A, B any](t T.Tuple2[A, B]) Pair[A, B]

FromTuple creates a Pair from a [T.Tuple2]

func MakePair

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

MakePair creates a Pair from two values

func MonadAp

func MonadAp[B, A, A1 any](sg Sg.Semigroup[B], faa Pair[func(A) A1, B], fa Pair[A, B]) Pair[A1, B]

MonadAp applies on the head value

func MonadApHead

func MonadApHead[B, A, A1 any](sg Sg.Semigroup[B], faa Pair[func(A) A1, B], fa Pair[A, B]) Pair[A1, B]

MonadApHead applies on the head value

func MonadApTail

func MonadApTail[A, B, B1 any](sg Sg.Semigroup[A], fbb Pair[A, func(B) B1], fb Pair[A, B]) Pair[A, B1]

MonadApTail applies on the Tail value

func MonadBiMap

func MonadBiMap[A, B, A1, B1 any](fa Pair[A, B], f func(A) A1, g func(B) B1) Pair[A1, B1]

MonadBiMap maps both values

func MonadChain

func MonadChain[B, A, A1 any](sg Sg.Semigroup[B], fa Pair[A, B], f func(A) Pair[A1, B]) Pair[A1, B]

MonadChain chains on the head value

func MonadChainHead

func MonadChainHead[B, A, A1 any](sg Sg.Semigroup[B], fa Pair[A, B], f func(A) Pair[A1, B]) Pair[A1, B]

MonadChainHead chains on the head value

func MonadChainTail

func MonadChainTail[A, B, B1 any](sg Sg.Semigroup[A], fb Pair[A, B], f func(B) Pair[A, B1]) Pair[A, B1]

MonadChainTail chains on the Tail value

func MonadMap

func MonadMap[B, A, A1 any](fa Pair[A, B], f func(A) A1) Pair[A1, B]

MonadMap maps the head value

func MonadMapHead

func MonadMapHead[B, A, A1 any](fa Pair[A, B], f func(A) A1) Pair[A1, B]

MonadMapHead maps the head value

func MonadMapTail

func MonadMapTail[A, B, B1 any](fa Pair[A, B], f func(B) B1) Pair[A, B1]

MonadMapTail maps the Tail value

func Of

func Of[A any](value A) Pair[A, A]

Of creates a Pair with the same value to to both fields

func Swap added in v1.0.128

func Swap[A, B any](fa Pair[A, B]) Pair[B, A]

Swap swaps the two channels

func (Pair[A, B]) Format

func (s Pair[A, B]) Format(f fmt.State, c rune)

Format prints some debug info for the object

func (Pair[A, B]) String

func (s Pair[A, B]) String() string

String prints some debug info for the object

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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