Module

Data.Tuple.Nested

Package
purescript-tuples
Repository
purescript/purescript-tuples

Utilities for n-tuples: sequences longer than two components built from nested pairs.

Nested tuples arise naturally in product combinators. You shouldn't represent data using nested tuples, but if combinators you're working with create them, utilities in this module will allow to to more easily work with them, including translating to and from more traditional product types.

data Address = Address String City (Maybe Province) Country

exampleAddress1 = makeAddress "221B Baker Street" London Nothing UK
exampleAddress2 = makeAddressT $ "221B Baker Street" /\ London /\ Nothing /\ UK

makeAddressT :: Tuple4 String City (Maybe Province) Country -> Address
makeAddressT = uncurry4 Address

makeAddress :: String -> City -> (Maybe Province) -> Country -> Address
makeAddress = curry4 unit makeAddressT

tupleAddress :: Address -> Tuple4 String City (Maybe Province) Country
tupleAddress (Address a b c d) = tuple4 a b c d

#(/\) Source

Operator alias for Data.Tuple.Tuple (right-associative / precedence 6)

Shorthand for constructing n-tuples as nested pairs. a /\ b /\ c /\ d /\ unit becomes Tuple a (Tuple b (Tuple c (Tuple d unit)))

#type (/\) Source

Operator alias for Data.Tuple.Tuple (right-associative / precedence 6)

Shorthand for constructing n-tuple types as nested pairs. forall a b c d. a /\ b /\ c /\ d /\ Unit becomes forall a b c d. Tuple a (Tuple b (Tuple c (Tuple d Unit)))

#Tuple1 Source

type Tuple1 a = T2 a Unit

#Tuple2 Source

type Tuple2 a b = T3 a b Unit

#Tuple3 Source

type Tuple3 a b c = T4 a b c Unit

#Tuple4 Source

type Tuple4 a b c d = T5 a b c d Unit

#Tuple5 Source

type Tuple5 a b c d e = T6 a b c d e Unit

#Tuple6 Source

type Tuple6 a b c d e f = T7 a b c d e f Unit

#Tuple7 Source

type Tuple7 a b c d e f g = T8 a b c d e f g Unit

#Tuple8 Source

type Tuple8 a b c d e f g h = T9 a b c d e f g h Unit

#Tuple9 Source

type Tuple9 a b c d e f g h i = T10 a b c d e f g h i Unit

#Tuple10 Source

type Tuple10 a b c d e f g h i j = T11 a b c d e f g h i j Unit

#T2 Source

type T2 a z = Tuple a z

#T3 Source

type T3 a b z = Tuple a (T2 b z)

#T4 Source

type T4 a b c z = Tuple a (T3 b c z)

#T5 Source

type T5 a b c d z = Tuple a (T4 b c d z)

#T6 Source

type T6 a b c d e z = Tuple a (T5 b c d e z)

#T7 Source

type T7 a b c d e f z = Tuple a (T6 b c d e f z)

#T8 Source

type T8 a b c d e f g z = Tuple a (T7 b c d e f g z)

#T9 Source

type T9 a b c d e f g h z = Tuple a (T8 b c d e f g h z)

#T10 Source

type T10 a b c d e f g h i z = Tuple a (T9 b c d e f g h i z)

#T11 Source

type T11 a b c d e f g h i j z = Tuple a (T10 b c d e f g h i j z)

#tuple1 Source

tuple1 :: forall a. a -> Tuple1 a

Creates a singleton tuple.

#tuple2 Source

tuple2 :: forall b a. a -> b -> Tuple2 a b

Given 2 values, creates a 2-tuple.

#tuple3 Source

tuple3 :: forall c b a. a -> b -> c -> Tuple3 a b c

Given 3 values, creates a nested 3-tuple.

#tuple4 Source

tuple4 :: forall d c b a. a -> b -> c -> d -> Tuple4 a b c d

Given 4 values, creates a nested 4-tuple.

#tuple5 Source

tuple5 :: forall e d c b a. a -> b -> c -> d -> e -> Tuple5 a b c d e

Given 5 values, creates a nested 5-tuple.

#tuple6 Source

tuple6 :: forall f e d c b a. a -> b -> c -> d -> e -> f -> Tuple6 a b c d e f

Given 6 values, creates a nested 6-tuple.

#tuple7 Source

tuple7 :: forall g f e d c b a. a -> b -> c -> d -> e -> f -> g -> Tuple7 a b c d e f g

Given 7 values, creates a nested 7-tuple.

#tuple8 Source

tuple8 :: forall h g f e d c b a. a -> b -> c -> d -> e -> f -> g -> h -> Tuple8 a b c d e f g h

Given 8 values, creates a nested 8-tuple.

#tuple9 Source

tuple9 :: forall i h g f e d c b a. a -> b -> c -> d -> e -> f -> g -> h -> i -> Tuple9 a b c d e f g h i

Given 9 values, creates a nested 9-tuple.

#tuple10 Source

tuple10 :: forall j i h g f e d c b a. a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> Tuple10 a b c d e f g h i j

Given 10 values, creates a nested 10-tuple.

#get1 Source

get1 :: forall z a. T2 a z -> a

Given at least a singleton tuple, gets the first value.

#get2 Source

get2 :: forall z b a. T3 a b z -> b

Given at least a 2-tuple, gets the second value.

#get3 Source

get3 :: forall z c b a. T4 a b c z -> c

Given at least a 3-tuple, gets the third value.

#get4 Source

get4 :: forall z d c b a. T5 a b c d z -> d

Given at least a 4-tuple, gets the fourth value.

#get5 Source

get5 :: forall z e d c b a. T6 a b c d e z -> e

Given at least a 5-tuple, gets the fifth value.

#get6 Source

get6 :: forall z f e d c b a. T7 a b c d e f z -> f

Given at least a 6-tuple, gets the sixth value.

#get7 Source

get7 :: forall z g f e d c b a. T8 a b c d e f g z -> g

Given at least a 7-tuple, gets the seventh value.

#get8 Source

get8 :: forall z h g f e d c b a. T9 a b c d e f g h z -> h

Given at least an 8-tuple, gets the eigth value.

#get9 Source

get9 :: forall z i h g f e d c b a. T10 a b c d e f g h i z -> i

Given at least a 9-tuple, gets the ninth value.

#get10 Source

get10 :: forall z j i h g f e d c b a. T11 a b c d e f g h i j z -> j

Given at least a 10-tuple, gets the tenth value.

#over1 Source

over1 :: forall z r a. (a -> r) -> T2 a z -> T2 r z

Given at least a singleton tuple, modifies the first value.

#over2 Source

over2 :: forall z r b a. (b -> r) -> T3 a b z -> T3 a r z

Given at least a 2-tuple, modifies the second value.

#over3 Source

over3 :: forall z r c b a. (c -> r) -> T4 a b c z -> T4 a b r z

Given at least a 3-tuple, modifies the third value.

#over4 Source

over4 :: forall z r d c b a. (d -> r) -> T5 a b c d z -> T5 a b c r z

Given at least a 4-tuple, modifies the fourth value.

#over5 Source

over5 :: forall z r e d c b a. (e -> r) -> T6 a b c d e z -> T6 a b c d r z

Given at least a 5-tuple, modifies the fifth value.

#over6 Source

over6 :: forall z r f e d c b a. (f -> r) -> T7 a b c d e f z -> T7 a b c d e r z

Given at least a 6-tuple, modifies the sixth value.

#over7 Source

over7 :: forall z r g f e d c b a. (g -> r) -> T8 a b c d e f g z -> T8 a b c d e f r z

Given at least a 7-tuple, modifies the seventh value.

#over8 Source

over8 :: forall z r h g f e d c b a. (h -> r) -> T9 a b c d e f g h z -> T9 a b c d e f g r z

Given at least an 8-tuple, modifies the eighth value.

#over9 Source

over9 :: forall z r i h g f e d c b a. (i -> r) -> T10 a b c d e f g h i z -> T10 a b c d e f g h r z

Given at least a 9-tuple, modifies the ninth value.

#over10 Source

over10 :: forall z r j i h g f e d c b a. (j -> r) -> T11 a b c d e f g h i j z -> T11 a b c d e f g h i r z

Given at least a 10-tuple, modifies the tenth value.

#uncurry1 Source

uncurry1 :: forall z r a. (a -> r) -> T2 a z -> r

Given a function of 1 argument, returns a function that accepts a singleton tuple.

#uncurry2 Source

uncurry2 :: forall z r b a. (a -> b -> r) -> T3 a b z -> r

Given a function of 2 arguments, returns a function that accepts a 2-tuple.

#uncurry3 Source

uncurry3 :: forall z r c b a. (a -> b -> c -> r) -> T4 a b c z -> r

Given a function of 3 arguments, returns a function that accepts a 3-tuple.

#uncurry4 Source

uncurry4 :: forall z r d c b a. (a -> b -> c -> d -> r) -> T5 a b c d z -> r

Given a function of 4 arguments, returns a function that accepts a 4-tuple.

#uncurry5 Source

uncurry5 :: forall z r e d c b a. (a -> b -> c -> d -> e -> r) -> T6 a b c d e z -> r

Given a function of 5 arguments, returns a function that accepts a 5-tuple.

#uncurry6 Source

uncurry6 :: forall z r f e d c b a. (a -> b -> c -> d -> e -> f -> r) -> T7 a b c d e f z -> r

Given a function of 6 arguments, returns a function that accepts a 6-tuple.

#uncurry7 Source

uncurry7 :: forall z r g f e d c b a. (a -> b -> c -> d -> e -> f -> g -> r) -> T8 a b c d e f g z -> r

Given a function of 7 arguments, returns a function that accepts a 7-tuple.

#uncurry8 Source

uncurry8 :: forall z r h g f e d c b a. (a -> b -> c -> d -> e -> f -> g -> h -> r) -> T9 a b c d e f g h z -> r

Given a function of 8 arguments, returns a function that accepts an 8-tuple.

#uncurry9 Source

uncurry9 :: forall z r i h g f e d c b a. (a -> b -> c -> d -> e -> f -> g -> h -> i -> r) -> T10 a b c d e f g h i z -> r

Given a function of 9 arguments, returns a function that accepts a 9-tuple.

#uncurry10 Source

uncurry10 :: forall z r j i h g f e d c b a. (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> r) -> T11 a b c d e f g h i j z -> r

Given a function of 10 arguments, returns a function that accepts a 10-tuple.

#curry1 Source

curry1 :: forall z r a. z -> (T2 a z -> r) -> a -> r

Given a function that accepts at least a singleton tuple, returns a function of 1 argument.

#curry2 Source

curry2 :: forall z r b a. z -> (T3 a b z -> r) -> a -> b -> r

Given a function that accepts at least a 2-tuple, returns a function of 2 arguments.

#curry3 Source

curry3 :: forall z r c b a. z -> (T4 a b c z -> r) -> a -> b -> c -> r

Given a function that accepts at least a 3-tuple, returns a function of 3 arguments.

#curry4 Source

curry4 :: forall z r d c b a. z -> (T5 a b c d z -> r) -> a -> b -> c -> d -> r

Given a function that accepts at least a 4-tuple, returns a function of 4 arguments.

#curry5 Source

curry5 :: forall z r e d c b a. z -> (T6 a b c d e z -> r) -> a -> b -> c -> d -> e -> r

Given a function that accepts at least a 5-tuple, returns a function of 5 arguments.

#curry6 Source

curry6 :: forall z r f e d c b a. z -> (T7 a b c d e f z -> r) -> a -> b -> c -> d -> e -> f -> r

Given a function that accepts at least a 6-tuple, returns a function of 6 arguments.

#curry7 Source

curry7 :: forall z r g f e d c b a. z -> (T8 a b c d e f g z -> r) -> a -> b -> c -> d -> e -> f -> g -> r

Given a function that accepts at least a 7-tuple, returns a function of 7 arguments.

#curry8 Source

curry8 :: forall z r h g f e d c b a. z -> (T9 a b c d e f g h z -> r) -> a -> b -> c -> d -> e -> f -> g -> h -> r

Given a function that accepts at least an 8-tuple, returns a function of 8 arguments.

#curry9 Source

curry9 :: forall z r i h g f e d c b a. z -> (T10 a b c d e f g h i z -> r) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> r

Given a function that accepts at least a 9-tuple, returns a function of 9 arguments.

#curry10 Source

curry10 :: forall z r j i h g f e d c b a. z -> (T11 a b c d e f g h i j z -> r) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> r

Given a function that accepts at least a 10-tuple, returns a function of 10 arguments.