File: tuple_sections.rst

package info (click to toggle)
ghc 9.10.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 169,260 kB
  • sloc: haskell: 713,564; ansic: 84,184; cpp: 30,255; javascript: 9,003; sh: 7,870; fortran: 3,527; python: 3,228; asm: 2,523; makefile: 2,329; yacc: 1,570; lisp: 532; xml: 196; perl: 111; csh: 2
file content (43 lines) | stat: -rw-r--r-- 977 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
.. _tuple-sections:

Tuple sections
--------------

.. extension:: TupleSections
    :shortdesc: Enable tuple sections.

    :since: 6.12

    :status: Included in :extension:`GHC2024`, :extension:`GHC2021`

    Allow the use of tuple section syntax

The :extension:`TupleSections` extension enables partially applied
tuple constructors. For example, the following program ::

      (, True)

is considered to be an alternative notation for the more unwieldy
alternative ::

      \x -> (x, True)

You can omit any combination of arguments to the tuple, as in the
following ::

      (, "I", , , "Love", , 1337)

which translates to ::

      \a b c d -> (a, "I", b, c, "Love", d, 1337)

If you have `unboxed tuples <#unboxed-tuples>`__ enabled, tuple sections
will also be available for them, like so ::

      (# , True #)

Because there is no unboxed unit tuple, the following expression ::

      (# #)

continues to stand for the unboxed singleton tuple data constructor.