diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2020-12-22 13:28:37 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2020-12-22 13:28:37 +0000 |
commit | 5abaff7655fce2f98938b4183ff3021e29fa6c47 (patch) | |
tree | dfe198309a9f1c54708bf4c0811c37d2b813c426 | |
parent | 293100ad15e07733bdd9a69922dc84f77a334e58 (diff) | |
download | haskell-wip/T19051.tar.gz |
Document scoping of named wildcard type variableswip/T19051
See `Note [Scoping of named wildcards]` in GHC.Hs.Type
This lack of documentation came up in #19051.
-rw-r--r-- | docs/users_guide/exts/partial_type_signatures.rst | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/docs/users_guide/exts/partial_type_signatures.rst b/docs/users_guide/exts/partial_type_signatures.rst index 4d523dd80f..a6a4f73a6a 100644 --- a/docs/users_guide/exts/partial_type_signatures.rst +++ b/docs/users_guide/exts/partial_type_signatures.rst @@ -151,6 +151,20 @@ Besides an extra-constraints wildcard (see :ref:`extra-constraints-wildcard`), only named wildcards can occur in the constraints, e.g. the ``_x`` in ``Show _x``. +When :extension:`ScopedTypeVariables` is on, the named wildcards of a +function signature scope over the function body just like +explicitly-forall'd type variables (:ref:`scoped-type-variables`), +even though there is no explicit forall. For example: :: + + f :: _a -> _a + f x = let g :: _a -> _a + g = ... + in ... + +Here the named wildcard ``_a`` scopes over the body of ``f``, thereby +binding the occurrences of ``_a`` in the signature of ``g``. All +four occurrences stand for the same type. + Named wildcards *should not be confused with type variables*. Even though syntactically similar, named wildcards can unify with monotypes as well as be generalised over (and behave as type variables). |