flow-type-list
v4.1.0
Published
Type-level lists for Flow
Downloads
6
Readme
flow-type-list
Type-level lists for Flow
.
Getting Started
Install with npm
$ npm install --save-dev flow-type-list
or yarn
$ yarn add flow-type-list
and use it in your project.
import { ... } from 'flow-type-list';
API
Types
Nil
Represents an empty type list.
Cons<A, B>
Represents the joining of a head type and tail List
.
List<A, B>
A List<A, B>
is either Nil
or Cons<A, B>
.
$Head<L>
Utility type that returns the type of the head element of the given type list.
$Tail<L>
Utility type that returns the type of the tail type list of the given type list.
Cons1<A>
Represents a list with one type.
Cons2<A, B>
Represents a list with two types.
Cons3<A, B, C>
Represents a list with three types.
Cons4<A, B, C, D>
Represents a list with four types.
Cons5<A, B, C, D, E>
Represents a list with five types.
Cons6<A, B, C, D, E, F>
Represents a list with six types.
$A<L>
/ $First<L>
Utility type that returns the first type in the given type List
.
$B<L>
/ $Second<L>
Utility type that returns the second type in the given type List
.
$C<L>
/ $Third<L>
Utility type that returns the third type in the given type List
.
$D<L>
/ $Fourth<L>
Utility type that returns the fourth type in the given type List
.
$E<L>
/ $Fifth<L>
Utility type that returns the fifth type in the given type List
.
$F<L>
/ $Sixth<L>
Utility type that returns the sixth type in the given type List
.
$SwapA<L, A>
Utility type that swaps the given type into the first position of the given List
.
$SwapB<L, B>
Utility type that swaps the given type into the second position of the given List
.
$SwapC<L, C>
Utility type that swaps the given type into the third position of the given List
.
$SwapD<L, D>
Utility type that swaps the given type into the fourth position of the given List
.
$SwapE<L, E>
Utility type that swaps the given type into the fifth position of the given List
.
$SwapF<L, F>
Utility type that swaps the given type into the sixth position of the given List
.
Functions
cons(a, b)
<A, B: List<any, any>>(a: A, b: B) => Cons<A, B>
Joins the given value and List
into a new List
.
uncons(cons)
<A, B: List<any, any>>(cons: Cons<A, B>) => [A, B]
Separates the head value and tail List
of the given List
.
head(cons)
<A>(cons: Cons<A, any>) => A
Returns the head value of the given List
.
tail(cons)
<B: List<any, any>>(cons: Cons<any, B>) => B
Returns the tail List
of the given List
.
first(list) / a(list)
<A>(list: List<A, any>) => A
Returns the first value in the given List
.
second(list) / b(list)
<B>(list: List<any, List<B, any>>) => B
Returns the second value in the given List
.
third(list) / c(list)
<C>(list: List<any, List<any, List<C, any>>>) => C
Returns the third value in the given List
.
fourth(list) / d(list)
<D>(list: List<any, List<any, List<any, List<D, any>>>>) => D
Returns the fourth value in the given List
.
fifth(list) / e(list)
<E>(list: List<any, List<any, List<any, List<any, List<E, any>>>>>) => E
Returns the fifth value in the given List
.
sixth(list) / f(list)
<F>(list: List<any, List<any, List<any, List<any, List<any, List<F, any>>>>>>) => F
Returns the sixth value in the given List
.
cons1(a)
<A>(a: A) => Cons<A, Nil>
Creates a list with one value.
uncons1(list)
<A>(list: Cons<A, any>) => [A]
Deconstructs a List
with one value.
cons2(a, b)
<A, B>(a: A, b: B) => Cons<A, Cons<B, Nil>>
Creates a list with two values.
uncons2(list)
<A, B>(list: Cons<A, Cons<B, any>>) => [A, B]
Deconstructs a List
with two values.
cons3(a, b, c)
<A, B, C>(a: a, b: B, c: C) => Cons<A, Cons<B, Cons<C, Nil>>>
Creates a list with three values.
uncons3(list)
<A, B>(list: Cons<A, Cons<B, any>>) => [A, B]
Deconstructs a List
with three values.
cons4(a, b, c, d)
<A, B, C, D>(a: a, b: B, c: C, d: D) => Cons<A, Cons<B, Cons<C, Cons<D, Nil>>>>
Creates a list with four values.
uncons4(list)
<A, B, C, D>(list: Cons<A, Cons<B, Cons<C, Cons<D, any>>>>) => [A, B, C, D]
Deconstructs a List
with four values.
cons5(a, b, c, d, e)
<A, B, C, D, E>(a: a, b: B, c: C, d: D, e: E) => Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Nil>>>>>
Creates a list with five values.
uncons5(list)
<A, B, C, D, E>(list: Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, any>>>>>) => [A, B, C, D, E]
Deconstructs a List
with five values.
cons6(a, b, c, d, e, f)
<A, B, C, D, E, F>(a: a, b: B, c: C, d: D, e: E, f: F) => Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, Nil>>>>>>
Creates a list with six values.
uncons6(list)
<A, B, C, D, E, F>(list: Cons<A, Cons<B, Cons<C, Cons<D, Cons<E, Cons<F, any>>>>>>) => [A, B, C, D, E, F]
Deconstructs a List
with six values.