tuple-generic-0.5.0.0: Generic operations on tuples

Safe HaskellSafe
LanguageHaskell2010

Data.Tuple.Generic

Description

This module supports operations with tuples with up to 16 elements.

Generic accessors and setters aren't included – if you want that, consider using microlens, which is a dependency-free alternative to lens providing generic lenses for tuples. This package only gives you uncons and unsnoc, which can be used to get the 1st and last element respectively.

Synopsis

Documentation

cons :: TupleCons a b x => x -> a -> b Source

Prepend a value to a tuple.

>>> cons 0 (1,2,3)
(0,1,2,3)

uncons :: TupleCons a b x => b -> (x, a) Source

Split off the 1st element of a tuple.

>>> uncons (0,1,2,3)
(0,(1,2,3))

snoc :: TupleSnoc a b x => a -> x -> b Source

Append a value to a tuple.

>>> snoc (1,2,3) 4
(1,2,3,4)

unsnoc :: TupleSnoc a b x => b -> (a, x) Source

Split off the last element of a tuple.

>>> unsnoc (1,2,3,4)
((1,2,3),4)