From 8cef8af3286f3c98f2a02e65371b875d8791b687 Mon Sep 17 00:00:00 2001 From: David Kraeutmann Date: Mon, 7 Dec 2015 11:19:28 +0100 Subject: 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 --- docs/users_guide/7.12.1-notes.rst | 23 +++++++++++++++++++++++ docs/users_guide/glasgow_exts.rst | 8 ++++---- 2 files changed, 27 insertions(+), 4 deletions(-) (limited to 'docs') 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: :: -- cgit v1.2.1