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)))
- Modules
- Data.
Tuple - Data.
Tuple. Nested