tuple-classes: Working with n-ary tuples and functions; strict tuples

[ apache, data, library ] [ Propose Tags ] [ Report a vulnerability ]

Please see the README on Codeberg at https://codeberg.org/sjshuck/tuple-classes#readme


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.0.0, 1.0.1
Change log CHANGELOG.md
Dependencies assoc, base (>=4.9 && <5), binary, deepseq, hashable, strict, template-haskell [details]
License Apache-2.0
Copyright 2026 Steven Shuck
Author Steven Shuck
Maintainer stevenjshuck@gmail.com
Uploaded by SShuck at 2026-07-06T00:13:52Z
Category data
Home page https://codeberg.org/sjshuck/tuple-classes#readme
Bug tracker https://codeberg.org/sjshuck/tuple-classes/issues
Source repo head: git clone https://codeberg.org/sjshuck/tuple-classes
Distributions
Downloads 0 total (0 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-07-06 [all 1 reports]

Readme for tuple-classes-1.0.1

[back to package description]

tuple-classes

Hackage

Haskell facilities for manipulating n-ary tuples and functions in lazy and strict varieties, plus strict tuples.

{-# 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
{-# 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. and Each
  • Lennart Augustsson's Curry class
  • Mitchell Rosen's strict-tuple 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 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

Main Author

©2026 Steven Shuck