Skip to content

Commit

Permalink
Prefix form for MkSolo#
Browse files Browse the repository at this point in the history
  • Loading branch information
int-index committed Feb 21, 2024
1 parent 6edec29 commit 646e1fb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion proposals/0475-tuple-syntax.rst
Expand Up @@ -142,7 +142,7 @@ Proposed Change Specification
data Unit# = (# #)

type Solo# :: TYPE rep -> TYPE (TupleRep [rep])
data Solo# a = (# a #)
data Solo# a = MkSolo# a

type Tuple0# = Unit#
type Tuple1# = Solo#
Expand Down Expand Up @@ -275,6 +275,8 @@ Proposed Change Specification

#. With ``-XUnboxedTuples``, an occurrence of ``(# ty #)`` in type-syntax is a synonym for ``GHC.Types.Solo# ty``.

#. With ``-XUnboxedTuples``, an occurrence of ``(# x #)`` in term-syntax is a synonym for ``GHC.Types.MkSolo# x``.

#. With ``-XUnboxedTuples``, an occurrence of ``(#,,...,,#)`` where there are *n* commas (for *n* ≧ 1) in type-syntax
is a synonym for ``GHC.Types.Tuple<n+1>#``.

Expand Down Expand Up @@ -331,6 +333,10 @@ Proposed Change Specification
never types or type constructors. (Note that ``(...) =>`` is special syntax, not an occurrence of any of the types
listed above. See `below <#constraints-special-syntax>`_.)

#. An occurrence of ``(# x #)`` is a synonym for ``GHC.Types.MkSolo# x`` in both term- and type-syntax.
(It is not valid in types at the time of writing, as GHC is unable to promote unboxed tuples, but this concern
is separate from syntax.)

#. A use of ``(# ... | ... | ... #)``, where each of the ``...`` is filled in, (among other arities) is now disallowed.

#. An occurrence of ``GHC.Tuple.Tuple<n> ty1 ty2 ... ty<n>`` is pretty-printed as ``Tuple (ty1, ty2, ..., ty<n>)``.
Expand Down Expand Up @@ -463,6 +469,11 @@ Effect and Interactions
means either ``Tuple2# Int Bool`` (with ``-XNoListTuplePuns``) or ``Solo# (Tuple2 Int Bool)`` (with
``-XListTuplePuns``). Furthermore, ``Tuple# (Int#, Double#)`` would not kind-check with ``-XListTuplePuns``. So we avoid these problems by simply erroring in the 1-element case.

#. The name of the data constructor for unboxed 1-tuples is ``MkSolo#`` rather
than ``(# #)`` to distinguish it from the data constructor for 0-tuples.
The ambiguity only arises when the name is used unapplied.
When applied to an argument, ``MkSolo# a`` can be written and pretty-printed as ``(# a #)``.

Costs and Drawbacks
-------------------
1. This is one more feature to maintain, but the code would be pretty local.
Expand Down

0 comments on commit 646e1fb

Please sign in to comment.