From e30f757a54daca0f197f8012f06ec05b7766de32 Mon Sep 17 00:00:00 2001 From: Vladislav Zavialov Date: Wed, 21 Feb 2024 11:59:21 +0100 Subject: [PATCH] Prefix form for MkSolo# --- proposals/0475-tuple-syntax.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/proposals/0475-tuple-syntax.rst b/proposals/0475-tuple-syntax.rst index b115670047..27c775d7cd 100644 --- a/proposals/0475-tuple-syntax.rst +++ b/proposals/0475-tuple-syntax.rst @@ -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# @@ -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#``. @@ -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 ty1 ty2 ... ty`` is pretty-printed as ``Tuple (ty1, ty2, ..., ty)``. @@ -463,6 +469,12 @@ 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 by the user as ``(# a #)``, + and should be pretty-printed as ``(# a #)`` by GHC. + Costs and Drawbacks ------------------- 1. This is one more feature to maintain, but the code would be pretty local.