[Haskell-beginners] The (x:xs) in function parameter is a tuple?

Rein Henrichs rein.henrichs at gmail.com
Thu Feb 25 22:43:53 UTC 2016


Nan, generally speaking (e.g., in maths) tuples can contain any number of
elements. Haskell specifically disallows one-tuples because of the
ambiguity in parsing them. Instead, (expr) is just evaluated as expr. On
the other hand, it does allow (), which is a zero-tuple. Haskell's
compilers also impose an upper bound on the practical size of a tuple (for
modern GHC, that's 61, as Max mentioned) but that isn't a restriction of
the Haskell language itself. If you want, you can consider Identity a to be
a one-tuple, but it obviously doesn't use tuple syntax.

As a side note, a 1-tuple is occasionally called a monad in other
disciplines, while a monad is actually defined as a triple (a three-tuple)
in maths. None of that is relevant to Haskell though.

On Thu, Feb 25, 2016 at 7:14 AM Max Voit <max.voit+mlhb at with-eyes.net>
wrote:

> On Thu, 25 Feb 2016 07:49:56 +0800
> Nan Xiao <xiaonan830818 at gmail.com> wrote:
>
> > Rein referred "A tuple can have any number of elements", while Graham
> > referred "There's no "one-ple", or 1-tuple, in Haskell.". So which one
> > is right? The tuple at least contains 2 elements?
>
> There is no one-tuple; however, there's a zero-tuple. Also no arbitrary
> number of tuple elements allowed, due to definition (we're at 61 for
> some reason). Refer to
>
> http://hackage.haskell.org/package/ghc-prim-0.4.0.0/docs/GHC-Tuple.html
>
> best, Max
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160225/c36047d4/attachment.html>


More information about the Beginners mailing list