summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorDavid Kraeutmann <kane@kane.cx>2015-12-07 11:19:28 +0100
committerBen Gamari <ben@smart-cactus.org>2015-12-07 11:20:57 +0100
commit8cef8af3286f3c98f2a02e65371b875d8791b687 (patch)
tree98dbb8851c8496d1266d7a91625026ecd314de53 /docs
parent3d55e41e72dc32281744c52afea380c1db577ee1 (diff)
downloadhaskell-8cef8af3286f3c98f2a02e65371b875d8791b687.tar.gz
Re-export data family when exporting a data instance without an export list
Whenever a data instance is exported, the corresponding data family is exported, too. This allows one to write ``` -- Foo.hs module Foo where data family T a -- Bar.hs module Bar where import Foo data instance T Int = MkT -- Baz.hs module Baz where import Bar (T(MkT)) ``` In previous versions of GHC, this required a workaround explicit export list in `Bar`. Reviewers: bgamari, goldfire, austin Reviewed By: bgamari, goldfire Subscribers: goldfire, thomie Differential Revision: https://phabricator.haskell.org/D1573 GHC Trac Issues: #11164
Diffstat (limited to 'docs')
-rw-r--r--docs/users_guide/7.12.1-notes.rst23
-rw-r--r--docs/users_guide/glasgow_exts.rst8
2 files changed, 27 insertions, 4 deletions
diff --git a/docs/users_guide/7.12.1-notes.rst b/docs/users_guide/7.12.1-notes.rst
index 2e0ae6f18c..21ec1d39b3 100644
--- a/docs/users_guide/7.12.1-notes.rst
+++ b/docs/users_guide/7.12.1-notes.rst
@@ -109,6 +109,29 @@ Language
-- P is imported
import Foo (T(..))
+- Whenever a data instance is exported, the corresponding data family
+ is exported, too. This allows one to write ::
+
+ -- Foo.hs
+ module Foo where
+
+ data family T a
+
+ -- Bar.hs
+ module Bar where
+
+ import Foo
+
+ data instance T Int = MkT
+
+ -- Baz.hs
+ module Baz where
+
+ import Bar (T(MkT))
+
+ In previous versions of GHC, this required a workaround via an
+ explicit export list in Bar.
+
Compiler
diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst
index 93261a2227..7e448beb9c 100644
--- a/docs/users_guide/glasgow_exts.rst
+++ b/docs/users_guide/glasgow_exts.rst
@@ -6702,10 +6702,10 @@ Two things to watch out for:
data instance D Int = D1 | D2
Module Y exports all the entities defined in Y, namely the data
- constructors ``D1`` and ``D2``, *but not the data family* ``D``. That
- (annoyingly) means that you cannot selectively import Y selectively,
- thus "``import Y( D(D1,D2) )``", because Y does not export ``D``.
- Instead you should list the exports explicitly, thus:
+ constructors ``D1`` and ``D2``, and *implicitly* the data family ``D``,
+ even though it's defined in X.
+ This means you can write "``import Y( D(D1,D2) )``" *without*
+ giving an explicit export list like this:
::