# tuple-classes
[](https://hackage.haskell.org/package/tuple-classes)
Haskell facilities for manipulating _n_-ary tuples and functions in lazy and strict varieties, plus strict tuples.
```haskell
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeApplications #-}
import Data.Tuple.Classes (curryN', uncurryN')
-- Function wrapper that expects a unary function
printArgAndRun :: (Show a) => (a -> IO b) -> a -> IO b
printArgAndRun f x = do
print x
f x
-- But we have a ternary function
printTitleAndSum :: String -> Int -> Int -> IO ()
printTitleAndSum title i j = do
putStrLn title
print $ i + j
-- We can adapt them
printArgsTitleAndSum :: String -> Int -> Int -> IO ()
printArgsTitleAndSum =
curryN' @3 $ printArgAndRun $ uncurryN' @3 printTitleAndSum
main :: IO ()
main = printArgsTitleAndSum "Important identity" 26885 15184
```
```
StrictTuple3 "Important identity" 26885 15184
Important identity
42069
```
```haskell
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeApplications #-}
import Data.Tuple.Classes (TupleAt(..))
consTuple :: (TupleAt 1 a t u) => a -> t -> u
consTuple = tupleInsert @1
main :: IO ()
main = print $ consTuple 'x' $ consTuple False ("sequitur", "quodlibet")
```
```
('x',False,"sequitur","quodlibet")
```
## Prior art
* Edward Kmett's lens's [`Field1` etc.](https://hackage-content.haskell.org/package/lens-5.3.6/docs/Control-Lens-Tuple.html) and [`Each`](https://hackage-content.haskell.org/package/lens-5.3.6/docs/Control-Lens-Each.html#t:Each)
* Lennart Augustsson's [`Curry`](https://hackage.haskell.org/package/tuple-0.3.0.2/docs/Data-Tuple-Curry.html) class
* Mitchell Rosen's [strict-tuple](https://hackage.haskell.org/package/strict-tuple-0.1.5.4/docs/Data-Tuple-Strict.html) which unfortunately would need some unnecessary-looking breaking changes to suit this library:
* Removing `Biapplicative` instances in order to not depend on the heavy bifunctors package
* Removing `T1` and `T2` which conflict with the much more supported `Identity` and `Pair`
* [mangoiv's proof-of-concept](https://bin.mangoiv.com/note?id=d204d07f-6292-4eb7-9aff-4cabc78394b9) related to keyword args and arbitrary function arity
Credit to mango for suggesting the limitations of that approach and indirectly shaping this library's design.
## LLM contribution policy
https://en.wikipedia.org/wiki/TESCREAL
## License
[Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
## Main Author
©2026 Steven Shuck