Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

haskell

Why does this work

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

while this does not

print (True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True)
like image 482
cieplak Avatar asked Feb 12 '13 02:02

cieplak


1 Answers

Because there is Show instance for 15-tuple:

Prelude> :i (,,,,,,,,,,,,,,)
data (,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o
  = (,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o
    -- 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 there are no for 16-tuple:

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

See docs

AFAIK instances are hand-written somethere in ghc internal libraries, and it is unlikely anybody will need to show 16-tuple.

like image 71
Yuras Avatar answered Sep 18 '22 14:09

Yuras