[Git][ghc/ghc][wip/int-index/rta-docs] docs: Update info on RequiredTypeArguments
Vladislav Zavialov (@int-index)
gitlab at gitlab.haskell.org
Sun Aug 4 09:22:42 UTC 2024
Vladislav Zavialov pushed to branch wip/int-index/rta-docs at Glasgow Haskell Compiler / GHC
Commits:
2fa9275e by Vladislav Zavialov at 2024-08-04T12:22:34+03:00
docs: Update info on RequiredTypeArguments
Add a section on "types in terms" that were implemented in 8b2f70a202
and remove the now outdated suggestion of using `type` for them.
- - - - -
1 changed file:
- docs/users_guide/exts/required_type_arguments.rst
Changes:
=====================================
docs/users_guide/exts/required_type_arguments.rst
=====================================
@@ -262,15 +262,36 @@ Outside a required type argument, it is illegal to use ``type``:
r4 = type Int -- illegal use of ‘type’
-Finally, there are types that require the ``type`` keyword only due to
-limitations of the current implementation::
+Types in terms
+~~~~~~~~~~~~~~
- a1 = f (type (Int -> Bool)) -- function type
- a2 = f (type (Read T => T)) -- constrained type
- a3 = f (type (forall a. a)) -- universally quantified type
- a4 = f (type (forall a. Read a => String -> a)) -- a combination of the above
+**Since:** GHC 9.12
-This restriction will be relaxed in a future release of GHC.
+:extension:`RequiredTypeArguments` extends the grammar of term-level
+expressions with syntax that is typically found only in types:
+
+* function types: ``a -> b``, ``a ⊸ b``, ``a %m -> b``
+* constrained types: ``ctx => t``
+* universally quantified types: ``forall tvs. t``, ``forall tvs -> t``
+
+These so-called "types in terms" make it possible to pass any types as required
+type arguments::
+
+ a1 = f (Int -> Bool) -- function type
+ a2 = f (Int %1 -> String) -- linear function type
+ a3 = f (Read T => T) -- constrained type
+ a4 = f (forall a. a) -- universally quantified type
+ a5 = f (forall a. Read a => String -> a) -- a combination of the above
+
+A few limitations apply:
+
+* The ``*`` syntax of :extension:`StarIsType` is not available due to a
+ conflict with the multiplication operator.
+ What to do instead: use ``Type`` from the ``Data.Kind`` module.
+
+* The ``'`` syntax of :extension:`DataKinds` is not available due to a conflict
+ with :extension:`TemplateHaskell` name quotation.
+ What to do instead: simply omit the ``'``.
Effect on implicit quantification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2fa9275e3b5948ff0bd74e91df41355eff7a8b58
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2fa9275e3b5948ff0bd74e91df41355eff7a8b58
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240804/d4add2b8/attachment-0001.html>
More information about the ghc-commits
mailing list