[Haskell-cafe] history of tuples vs pairs

Isaac Dupree isaacdupree at charter.net
Thu Jun 26 06:54:05 EDT 2008


Lennart Augustsson wrote:
> Yes, early ML had nested pairs.  We introduced n-tuples in Lazy ML
> because in a lazy language n-tuples are not isomorphic to nested pairs
> (whereas they are in a strict language).  So n-tuples are nasty
> because they are not inductive, but they are in many ways much more
> reasonable than lazy nested pairs.

although it is possible in a slightly different (and less left-right 
symmetric) way in Haskell:
data P a b = P a !b
pair: P Int (P Bool ())
triple: P Char (P Int (P Bool ())
single: P Bool ()
unit: ()

> BTW, early ML also had binary sums.  Again, they are not isomorphic to
> n-ary sums.

data E a b = L a | R !b
data Z --since Haskell Prelude provides us with the unit type () but not 
the uninhabited "zero" type, I'll use GHC's EmptyDataDecls syntax for this.
either: E Int (E Bool Z)
3: E Char (E Int (E Bool Z)
1: E Bool Z
0: Z

Still, these don't have isomorphic *representations*: the efficiency is 
lacking.  I wonder if it would be possible to allow {-#UNPACK#-} for 
those polymorphic arguments in such a way that either/both of the above 
were actually equivalent to n-tuple/sums.

-Isaac


More information about the Haskell-Cafe mailing list