Options
All
  • Public
  • Public/Protected
  • All
Menu

Package tuple

@typed/tuple

Functions for working with pairs of values

Index

Type aliases

Variables

Functions

Type aliases

First

First<A>: A[0]

Type parameters

Second

Second<A>: A[1]

Type parameters

Tuple

Tuple<A, B>: keyof [A, B]

Type parameters

  • A

  • B

Variables

Const ap

ap: { <A, B, C>(fn: Tuple<A, Arity1<B, C>>, value: Tuple<A, B>): Tuple<A, C>; <A, B, C>(fn: Tuple<A, Arity1<B, C>>): (value: Tuple<A, B>) => Tuple<A, C> } = curry(<A, B, C>(fn: Tuple<A, Arity1<B, C>>, value: Tuple<A, B>): Tuple<A, C> =>chain((f) => map(f, value), fn),)

Apply the function in a tuple to the values in another using the second value.

param

:: Tuple a (b -> Tuple a c)

param

:: Tuple a b

returns

Tuple a c

Type declaration

Const apLeft

apLeft: { <A, B, C>(fn: Tuple<Arity1<A, C>, B>, tuple: Tuple<A, B>): Tuple<C, B>; <A, B, C>(fn: Tuple<Arity1<A, C>, B>): (tuple: Tuple<A, B>) => Tuple<C, B> } = curry(<A, B, C>(fn: Tuple<Arity1<A, C>, B>, tuple: Tuple<A, B>): Tuple<C, B> =>chainLeft((f) => mapLeft(f, tuple), fn),)

Apply the function in a tuple to the values in another using the left value.

param

:: Tuple (a -> Tuple a c) b

param

:: Tuple a b

returns

Tuple a c

Type declaration

Const chain

chain: { <A, B, C>(fn: Arity1<B, Tuple<A, C>>, tuple: Tuple<A, B>): Tuple<A, C>; <A, B, C>(fn: Arity1<B, Tuple<A, C>>): (tuple: Tuple<A, B>) => Tuple<A, C> } = curry(<A, B, C>(fn: Arity1<B, Tuple<A, C>>, tuple: Tuple<A, B>): Tuple<A, C> => fn(second(tuple)),)

Chain together tuples using the second value of a given tuple.

param

:: (b -> Tuple a c)

param

:: Tuple a b

returns

Tuple a c

Type declaration

Const chainLeft

chainLeft: { <A, B, C>(fn: Arity1<A, Tuple<C, B>>, tuple: Tuple<A, B>): Tuple<C, B>; <A, B, C>(fn: Arity1<A, Tuple<C, B>>): (tuple: Tuple<A, B>) => Tuple<C, B> } = curry(<A, B, C>(fn: Arity1<A, Tuple<C, B>>, tuple: Tuple<A, B>): Tuple<C, B> => fn(first(tuple)),)

Chain together tuples using the first value of a given tuple.

param

:: (a -> Tuple a c)

param

:: Tuple a b

returns

Tuple a c

Type declaration

Const map

map: { <A, B, C>(fn: Arity1<B, C>, tuple: Tuple<A, B>): Tuple<A, C>; <A, B, C>(fn: Arity1<B, C>): (tuple: Tuple<A, B>) => Tuple<A, C> } = curry(<A, B, C>(fn: Arity1<B, C>, tuple: Tuple<A, B>): Tuple<A, C> => [first(tuple), fn(second(tuple))],)

Map the second value of a tuple

param

(b -> c)

param

:: Tuple a b

returns

:: Tuple a c

Type declaration

Const mapLeft

mapLeft: { <A, B, C>(fn: Arity1<A, C>, tuple: Tuple<A, B>): Tuple<C, B>; <A, B, C>(fn: Arity1<A, C>): (tuple: Tuple<A, B>) => Tuple<C, B> } = curry(<A, B, C>(fn: Arity1<A, C>, tuple: Tuple<A, B>): Tuple<C, B> => [fn(first(tuple)), second(tuple)],)

Map the first value of a tuple

param

(a -> c)

param

:: Tuple a b

returns

:: Tuple c b

Type declaration

Functions

Const first

  • first<T>(tuple: T): First<T>

Const second

  • second<T>(tuple: T): Second<T>

Const swap

Generated using TypeDoc