summaryrefslogtreecommitdiff
path: root/docs/users_guide
diff options
context:
space:
mode:
authorVladislav Zavialov <vlad.z.4096@gmail.com>2018-07-16 18:46:52 -0400
committerBen Gamari <ben@smart-cactus.org>2018-07-16 18:46:53 -0400
commit65c186f0fdde95fd7c63ab9bd9b33a0213dba7d1 (patch)
tree92abe9e3aeab1711db0e77361c453ee49f48ef55 /docs/users_guide
parent7fe4993673e43e5b21f38d79ecc8b5163e97ee84 (diff)
downloadhaskell-65c186f0fdde95fd7c63ab9bd9b33a0213dba7d1.tar.gz
Do not imply NoStarIsType by TypeOperators/TypeInType
Implementation of the "Embrace TypeInType" proposal was done according to the spec, which specified that TypeOperators must imply NoStarIsType. This implication was meant to prevent breakage and to be removed in 2 releases. However, compiling head.hackage has shown that this implication only magnified the breakage, so there is no reason to have it in the first place. To remain in compliance with the three-release policy, we add a workaround to define the (*) type operator even when -XStarIsType is on. Test Plan: ./validate Reviewers: bgamari, RyanGlScott, goldfire, phadej, hvr Reviewed By: bgamari, RyanGlScott Subscribers: harpocrates, rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4865
Diffstat (limited to 'docs/users_guide')
-rw-r--r--docs/users_guide/8.6.1-notes.rst3
-rw-r--r--docs/users_guide/glasgow_exts.rst8
-rw-r--r--docs/users_guide/using-warnings.rst31
3 files changed, 35 insertions, 7 deletions
diff --git a/docs/users_guide/8.6.1-notes.rst b/docs/users_guide/8.6.1-notes.rst
index 72a3790bfd..3a24384493 100644
--- a/docs/users_guide/8.6.1-notes.rst
+++ b/docs/users_guide/8.6.1-notes.rst
@@ -51,8 +51,7 @@ Language
- A new :extension:`StarIsType` language extension has been added which controls
whether ``*`` is parsed as ``Data.Kind.Type`` or a regular type operator.
- :extension:`StarIsType` is enabled by default and disabled by
- :extension:`TypeOperators`.
+ :extension:`StarIsType` is enabled by default.
- GHC now permits the use of a wildcard type as the context of a standalone
``deriving`` declaration with the use of the
diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst
index 14d01f6123..5cf5c583ad 100644
--- a/docs/users_guide/glasgow_exts.rst
+++ b/docs/users_guide/glasgow_exts.rst
@@ -8712,8 +8712,7 @@ Kind polymorphism
.. extension:: TypeInType
:shortdesc: Deprecated. Enable kind polymorphism and datatype promotion.
- :implies: :extension:`PolyKinds`, :extension:`DataKinds`, :extension:`KindSignatures`,
- :extension:`NoStarIsType`
+ :implies: :extension:`PolyKinds`, :extension:`DataKinds`, :extension:`KindSignatures`
:since: 8.0.1
In the past this extension used to enable advanced type-level programming
@@ -9160,13 +9159,12 @@ The kind ``Type``
-----------------
.. extension:: StarIsType
- :shortdesc: Desugar ``*`` to ``Data.Kind.Type``.
+ :shortdesc: Treat ``*`` as ``Data.Kind.Type``.
:since: 8.6.1
Treat the unqualified uses of the ``*`` type operator as nullary and desugar
- to ``Data.Kind.Type``. Disabled by :extension:`TypeOperators` and
- :extension:`TypeInType`.
+ to ``Data.Kind.Type``.
The kind ``Type`` (imported from ``Data.Kind``) classifies ordinary types. With
:extension:`StarIsType` (currently enabled by default), ``*`` is desugared to
diff --git a/docs/users_guide/using-warnings.rst b/docs/users_guide/using-warnings.rst
index 575e28119f..8d09b4488b 100644
--- a/docs/users_guide/using-warnings.rst
+++ b/docs/users_guide/using-warnings.rst
@@ -34,6 +34,7 @@ generally likely to indicate bugs in your program. These are:
* :ghc-flag:`-Wtabs`
* :ghc-flag:`-Wunrecognised-warning-flags`
* :ghc-flag:`-Winaccessible-code`
+ * :ghc-flag:`-Wstar-binder`
The following flags are simple ways to select standard "packages" of warnings:
@@ -1169,6 +1170,36 @@ of ``-W(no-)*``.
since we're passing ``Foo1`` and ``Foo2`` here, it follows that ``t ~
Char``, and ``u ~ Int``, and thus ``t ~ u`` cannot hold.
+.. ghc-flag:: -Wstar-binder
+ :shortdesc: warn about binding the ``(*)`` type operator despite
+ :ghc-flag:`-XStarIsType`
+ :type: dynamic
+ :reverse: -Wno-star-binder
+
+ Under :ghc-flag:`-XStarIsType`, a ``*`` in types is not an operator nor
+ even a name, it is special syntax that stands for ``Data.Kind.Type``. This
+ means that an expression like ``Either * Char`` is parsed as ``Either (*)
+ Char`` and not ``(*) Either Char``.
+
+ In binding positions, we have similar parsing rules. Consider the following
+ example ::
+
+ {-# LANGUAGE TypeOperators, TypeFamilies, StarIsType #-}
+
+ type family a + b
+ type family a * b
+
+ While ``a + b`` is parsed as ``(+) a b`` and becomes a binding position for
+ the ``(+)`` type operator, ``a * b`` is parsed as ``a (*) b`` and is rejected.
+
+ As a workaround, we allow to bind ``(*)`` in prefix form::
+
+ type family (*) a b
+
+ This is a rather fragile arrangement, as generally a programmer expects
+ ``(*) a b`` to be equivalent to ``a * b``. With :ghc-flag:`-Wstar-binder`
+ we warn when this special treatment of ``(*)`` takes place.
+
.. ghc-flag:: -Wsimplifiable-class-constraints
:shortdesc: 2arn about class constraints in a type signature that can
be simplified using a top-level instance declaration.