Why does the GHC print 15 tuples but not 16 tuples?

Why is this work

print (True, True, True, True, True, True, True, True, True, True, True, True, True, True, True) 

until it

 print (True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True) 
+6
source share
2 answers

Since there is a Show instance for 15 tuples:

 Prelude> :i (,,,,,,,,,,,,,,) data (,,,,,,,,,,,,,,) abcdefghijklmno = (,,,,,,,,,,,,,,) abcdefghijklmno -- Defined in `GHC.Tuple' <<skip>> instance (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n, Read o) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -- Defined in `GHC.Read' instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m, Show n, Show o) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -- Defined in `GHC.Show' 

And not for 16-tuples:

 Prelude> :i (,,,,,,,,,,,,,,,) data (,,,,,,,,,,,,,,,) abcdefghijklmnop = (,,,,,,,,,,,,,,,) abcdefghijklmnop -- Defined in `GHC.Tuple' 

See docs

AFAIK instances are hand-written in the ghc internal libraries, and hardly anyone needs to show a 16-tuple.

+11
source

This is defined in the Haskell report Section 6.1.4 Tuples :

There is no upper bound on the tuple size, but some Haskell implementations may limit the size of the tuples and limit the instances associated with large tuples. However, each Haskell implementation must support tuples of up to 15, as well as instances for Eq, Ord, Bounded, Read, and Show. Prelude and libraries define functions such as zip for tuples up to 7 in size.

+7
source

All Articles