diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2016-09-05 19:19:23 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-09-08 10:43:57 -0400 |
commit | feaa31fbc41685d69045ac8d34be4e18f4f27ffd (patch) | |
tree | 0e2abfc6660337a432c87e65d867619b9db1afe2 /docs | |
parent | dcc49044e8ac5b905955f99b042449635eb47e64 (diff) | |
download | haskell-feaa31fbc41685d69045ac8d34be4e18f4f27ffd.tar.gz |
Remove references to -XRelaxedPolyRec
Test Plan: Read it
Reviewers: dfeuer, austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2515
GHC Trac Issues: #11691
Diffstat (limited to 'docs')
-rw-r--r-- | docs/users_guide/bugs.rst | 51 | ||||
-rw-r--r-- | docs/users_guide/glasgow_exts.rst | 62 |
2 files changed, 51 insertions, 62 deletions
diff --git a/docs/users_guide/bugs.rst b/docs/users_guide/bugs.rst index 5d303636f4..875820b399 100644 --- a/docs/users_guide/bugs.rst +++ b/docs/users_guide/bugs.rst @@ -126,6 +126,57 @@ been decided to remove them from the next version of the language standard. This behaviour can be controlled with the ``DatatypeContexts`` extension. See :ref:`datatype-contexts`. +.. _infelicities-recursive-groups: + +Typechecking of recursive binding groups +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The Haskell Report specifies that a group of bindings (at top level, or +in a ``let`` or ``where``) should be sorted into strongly-connected +components, and then type-checked in dependency order +(`Haskell Report, Section +4.5.1 <http://www.haskell.org/onlinereport/decls.html#sect4.5.1>`__). As +each group is type-checked, any binders of the group that have an +explicit type signature are put in the type environment with the +specified polymorphic type, and all others are monomorphic until the +group is generalised (`Haskell Report, Section +4.5.2 <http://www.haskell.org/onlinereport/decls.html#sect4.5.2>`__). + +Following a suggestion of Mark Jones, in his paper `Typing Haskell in +Haskell <http://citeseer.ist.psu.edu/424440.html>`__, GHC implements a +more general scheme. In GHC *the dependency analysis ignores references to +variables that have an explicit type signature*. As a result of this refined +dependency analysis, the dependency groups are smaller, and more bindings will +typecheck. For example, consider: :: + + f :: Eq a => a -> Bool + f x = (x == x) || g True || g "Yes" + + g y = (y <= y) || f True + +This is rejected by Haskell 98, but under Jones's scheme the definition +for ``g`` is typechecked first, separately from that for ``f``, because +the reference to ``f`` in ``g``\'s right hand side is ignored by the +dependency analysis. Then ``g``\'s type is generalised, to get :: + + g :: Ord a => a -> Bool + +Now, the definition for ``f`` is typechecked, with this type for ``g`` +in the type environment. + +The same refined dependency analysis also allows the type signatures of +mutually-recursive functions to have different contexts, something that is +illegal in Haskell 98 (Section 4.5.2, last sentence). GHC only insists that the +type signatures of a *refined* group have identical type signatures; in practice +this means that only variables bound by the same pattern binding must have the +same context. For example, this is fine: :: + + f :: Eq a => a -> Bool + f x = (x == x) || g True + + g :: Ord a => a -> Bool + g y = (y <= y) || f True + .. _infelicities-Modules: Module system and interface files diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 7709b2257f..62095486b6 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -8412,7 +8412,6 @@ Lexically scoped type variables .. ghc-flag:: -XScopedTypeVariables - :implies: :ghc-flag:`-XRelaxedPolyRec` :implies: :ghc-flag:`-XExplicitForAll` Enable lexical scoping of type variables explicitly introduced with @@ -8436,9 +8435,6 @@ signature for ``ys``. In Haskell 98 it is not possible to declare a type for ``ys``; a major benefit of scoped type variables is that it becomes possible to do so. -Lexically-scoped type variables are enabled by -:ghc-flag:`-XScopedTypeVariables`. This flag implies :ghc-flag:`-XRelaxedPolyRec`. - Overview -------- @@ -8651,64 +8647,6 @@ the Haskell Report) can be completely switched off by restriction is switched off by default in GHCi's interactive options (see :ref:`ghci-interactive-options`). -.. _typing-binds: - -Generalised typing of mutually recursive bindings -------------------------------------------------- - -.. ghc-flag:: -XRelaxedPolyRec - - Allow the typechecker to ignore references to bindings with - explicit type signatures. - -The Haskell Report specifies that a group of bindings (at top level, or -in a ``let`` or ``where``) should be sorted into strongly-connected -components, and then type-checked in dependency order -(`Haskell Report, Section -4.5.1 <http://www.haskell.org/onlinereport/decls.html#sect4.5.1>`__). As -each group is type-checked, any binders of the group that have an -explicit type signature are put in the type environment with the -specified polymorphic type, and all others are monomorphic until the -group is generalised (`Haskell Report, Section -4.5.2 <http://www.haskell.org/onlinereport/decls.html#sect4.5.2>`__). - -Following a suggestion of Mark Jones, in his paper `Typing Haskell in -Haskell <http://citeseer.ist.psu.edu/424440.html>`__, GHC implements a -more general scheme. If :ghc-flag:`-XRelaxedPolyRec` is specified: *the -dependency analysis ignores references to variables that have an -explicit type signature*. As a result of this refined dependency -analysis, the dependency groups are smaller, and more bindings will -typecheck. For example, consider: :: - - f :: Eq a => a -> Bool - f x = (x == x) || g True || g "Yes" - - g y = (y <= y) || f True - -This is rejected by Haskell 98, but under Jones's scheme the definition -for ``g`` is typechecked first, separately from that for ``f``, because -the reference to ``f`` in ``g``\'s right hand side is ignored by the -dependency analysis. Then ``g``\'s type is generalised, to get :: - - g :: Ord a => a -> Bool - -Now, the definition for ``f`` is typechecked, with this type for ``g`` -in the type environment. - -The same refined dependency analysis also allows the type signatures of -mutually-recursive functions to have different contexts, something that -is illegal in Haskell 98 (Section 4.5.2, last sentence). With -:ghc-flag:`-XRelaxedPolyRec` GHC only insists that the type signatures of a -*refined* group have identical type signatures; in practice this means -that only variables bound by the same pattern binding must have the same -context. For example, this is fine: :: - - f :: Eq a => a -> Bool - f x = (x == x) || g True - - g :: Ord a => a -> Bool - g y = (y <= y) || f True - .. _mono-local-binds: Let-generalisation |