Move Extension type to ghc-boot-th
authorBen Gamari <bgamari.foss@gmail.com>
Mon, 16 May 2016 13:21:34 +0000 (15:21 +0200)
committerBen Gamari <ben@smart-cactus.org>
Mon, 16 May 2016 14:22:05 +0000 (16:22 +0200)
This creates a new package, `ghc-boot-th`, to contain the `Extension`
type, which now lives in `GHC.LanguageExtension.Type`. This ensures that
the transitive dependency set of the `template-haskell` package remains
minimal.

The `GHC.LanguageExtensions.Type` module is also re-exported by
`ghc-boot`, which provides an orphan `binary` instance as well.

Test Plan: Validate

Reviewers: goldfire, thomie, hvr, austin

Reviewed By: thomie

Subscribers: RyanGlScott, thomie, erikd, ezyang

Differential Revision: https://phabricator.haskell.org/D2224

16 files changed:
.gitignore
compiler/main/DynFlags.hs
configure.ac
ghc.mk
libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs [new file with mode: 0644]
libraries/ghc-boot-th/GHC/Lexeme.hs [moved from libraries/ghc-boot/GHC/Lexeme.hs with 100% similarity]
libraries/ghc-boot-th/LICENSE [new file with mode: 0644]
libraries/ghc-boot-th/changelog.md [new file with mode: 0644]
libraries/ghc-boot-th/ghc-boot-th.cabal.in [new file with mode: 0644]
libraries/ghc-boot/GHC/LanguageExtensions.hs
libraries/ghc-boot/changelog.md
libraries/ghc-boot/ghc-boot.cabal.in
libraries/template-haskell/Language/Haskell/TH/LanguageExtensions.hs
libraries/template-haskell/template-haskell.cabal
testsuite/tests/th/TH_Roles2.stderr
testsuite/tests/th/all.T

index bc95f12..ff87375 100644 (file)
@@ -129,6 +129,9 @@ _darcs/
 /libraries/ghc-boot/GNUmakefile
 /libraries/ghc-boot/ghc-boot.cabal
 /libraries/ghc-boot/ghc.mk
+/libraries/ghc-boot-th/GNUmakefile
+/libraries/ghc-boot-th/ghc-boot-th.cabal
+/libraries/ghc-boot-th/ghc.mk
 /libraries/ghci/ghci.cabal
 /libraries/ghci/ghc.mk
 /libraries/haddock-util.js
index 00a25cd..666748a 100644 (file)
@@ -240,8 +240,8 @@ import qualified GHC.LanguageExtensions as LangExt
 --
 --  * Adding the extension to GHC.LanguageExtensions
 --
---    The Extension type in libraries/ghc-boot/GHC/LanguageExtensions.hs is
---    the canonical list of language extensions known by GHC.
+--    The Extension type in libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs
+--    is the canonical list of language extensions known by GHC.
 --
 --  * Adding a flag to DynFlags.xFlags
 --
index defc182..ff0dc05 100644 (file)
@@ -1127,7 +1127,7 @@ checkMake380() {
 checkMake380 make
 checkMake380 gmake
 
-AC_CONFIG_FILES([mk/config.mk mk/install.mk mk/project.mk compiler/ghc.cabal ghc/ghc-bin.cabal utils/runghc/runghc.cabal libraries/ghc-boot/ghc-boot.cabal libraries/ghci/ghci.cabal settings docs/users_guide/ghc_config.py docs/index.html libraries/prologue.txt distrib/configure.ac])
+AC_CONFIG_FILES([mk/config.mk mk/install.mk mk/project.mk compiler/ghc.cabal ghc/ghc-bin.cabal utils/runghc/runghc.cabal libraries/ghc-boot/ghc-boot.cabal libraries/ghc-boot-th/ghc-boot-th.cabal libraries/ghci/ghci.cabal settings docs/users_guide/ghc_config.py docs/index.html libraries/prologue.txt distrib/configure.ac])
 AC_OUTPUT
 
 if test "$print_make_warning" = "true"; then
diff --git a/ghc.mk b/ghc.mk
index a9f5b06..a767e35 100644 (file)
--- a/ghc.mk
+++ b/ghc.mk
@@ -430,7 +430,7 @@ else # CLEANING
 # programs such as GHC and ghc-pkg, that we do not assume the stage0
 # compiler already has installed (or up-to-date enough).
 
-PACKAGES_STAGE0 = binary Cabal/Cabal hpc ghc-boot hoopl transformers template-haskell
+PACKAGES_STAGE0 = binary Cabal/Cabal hpc ghc-boot-th ghc-boot hoopl transformers template-haskell
 ifeq "$(Windows_Host)" "NO"
 ifneq "$(HostOS_CPP)" "ios"
 PACKAGES_STAGE0 += terminfo
@@ -460,6 +460,7 @@ PACKAGES_STAGE1 += hpc
 PACKAGES_STAGE1 += pretty
 PACKAGES_STAGE1 += binary
 PACKAGES_STAGE1 += Cabal/Cabal
+PACKAGES_STAGE1 += ghc-boot-th
 PACKAGES_STAGE1 += ghc-boot
 PACKAGES_STAGE1 += template-haskell
 PACKAGES_STAGE1 += hoopl
diff --git a/libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs b/libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs
new file mode 100644 (file)
index 0000000..39613b0
--- /dev/null
@@ -0,0 +1,132 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  GHC.LanguageExtensions.Type
+-- Copyright   :  (c) The GHC Team
+--
+-- Maintainer  :  ghc-devs@haskell.org
+-- Portability :  portable
+--
+-- A data type defining the language extensions supported by GHC.
+--
+{-# LANGUAGE DeriveGeneric #-}
+module GHC.LanguageExtensions.Type ( Extension(..) ) where
+
+import GHC.Generics
+
+-- | The language extensions known to GHC.
+--
+-- Note that there is an orphan 'Binary' instance for this type supplied by
+-- the "GHC.LanguageExtensions" module provided by @ghc-boot@. We can't provide
+-- here as this would require adding transitive dependencies to the
+-- @template-haskell@ package, which must have a minimal dependency set.
+data Extension
+-- See Note [Updating flag description in the User's Guide] in DynFlags
+   = Cpp
+   | OverlappingInstances
+   | UndecidableInstances
+   | IncoherentInstances
+   | UndecidableSuperClasses
+   | MonomorphismRestriction
+   | MonoPatBinds
+   | MonoLocalBinds
+   | RelaxedPolyRec           -- Deprecated
+   | ExtendedDefaultRules     -- Use GHC's extended rules for defaulting
+   | ForeignFunctionInterface
+   | UnliftedFFITypes
+   | InterruptibleFFI
+   | CApiFFI
+   | GHCForeignImportPrim
+   | JavaScriptFFI
+   | ParallelArrays           -- Syntactic support for parallel arrays
+   | Arrows                   -- Arrow-notation syntax
+   | TemplateHaskell
+   | TemplateHaskellQuotes    -- subset of TH supported by stage1, no splice
+   | QuasiQuotes
+   | ImplicitParams
+   | ImplicitPrelude
+   | ScopedTypeVariables
+   | AllowAmbiguousTypes
+   | UnboxedTuples
+   | BangPatterns
+   | TypeFamilies
+   | TypeFamilyDependencies
+   | TypeInType
+   | OverloadedStrings
+   | OverloadedLists
+   | NumDecimals
+   | DisambiguateRecordFields
+   | RecordWildCards
+   | RecordPuns
+   | ViewPatterns
+   | GADTs
+   | GADTSyntax
+   | NPlusKPatterns
+   | DoAndIfThenElse
+   | RebindableSyntax
+   | ConstraintKinds
+   | PolyKinds                -- Kind polymorphism
+   | DataKinds                -- Datatype promotion
+   | InstanceSigs
+   | ApplicativeDo
+
+   | StandaloneDeriving
+   | DeriveDataTypeable
+   | AutoDeriveTypeable       -- Automatic derivation of Typeable
+   | DeriveFunctor
+   | DeriveTraversable
+   | DeriveFoldable
+   | DeriveGeneric            -- Allow deriving Generic/1
+   | DefaultSignatures        -- Allow extra signatures for defmeths
+   | DeriveAnyClass           -- Allow deriving any class
+   | DeriveLift               -- Allow deriving Lift
+
+   | TypeSynonymInstances
+   | FlexibleContexts
+   | FlexibleInstances
+   | ConstrainedClassMethods
+   | MultiParamTypeClasses
+   | NullaryTypeClasses
+   | FunctionalDependencies
+   | UnicodeSyntax
+   | ExistentialQuantification
+   | MagicHash
+   | EmptyDataDecls
+   | KindSignatures
+   | RoleAnnotations
+   | ParallelListComp
+   | TransformListComp
+   | MonadComprehensions
+   | GeneralizedNewtypeDeriving
+   | RecursiveDo
+   | PostfixOperators
+   | TupleSections
+   | PatternGuards
+   | LiberalTypeSynonyms
+   | RankNTypes
+   | ImpredicativeTypes
+   | TypeOperators
+   | ExplicitNamespaces
+   | PackageImports
+   | ExplicitForAll
+   | AlternativeLayoutRule
+   | AlternativeLayoutRuleTransitional
+   | DatatypeContexts
+   | NondecreasingIndentation
+   | RelaxedLayout
+   | TraditionalRecordSyntax
+   | LambdaCase
+   | MultiWayIf
+   | BinaryLiterals
+   | NegativeLiterals
+   | DuplicateRecordFields
+   | OverloadedLabels
+   | EmptyCase
+   | PatternSynonyms
+   | PartialTypeSignatures
+   | NamedWildCards
+   | StaticPointers
+   | TypeApplications
+   | Strict
+   | StrictData
+   | MonadFailDesugaring
+   deriving (Eq, Enum, Show, Generic)
diff --git a/libraries/ghc-boot-th/LICENSE b/libraries/ghc-boot-th/LICENSE
new file mode 100644 (file)
index 0000000..b5059b7
--- /dev/null
@@ -0,0 +1,31 @@
+The Glasgow Haskell Compiler License
+
+Copyright 2002, The University Court of the University of Glasgow. 
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+- Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+- Neither name of the University nor the names of its contributors may be
+used to endorse or promote products derived from this software without
+specific prior written permission. 
+
+THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
+GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
diff --git a/libraries/ghc-boot-th/changelog.md b/libraries/ghc-boot-th/changelog.md
new file mode 100644 (file)
index 0000000..3ed5bbb
--- /dev/null
@@ -0,0 +1,5 @@
+## 8.0.1  *May 2016*
+
+  * Bundled with GHC 8.0.1
+
+  * Initial version
diff --git a/libraries/ghc-boot-th/ghc-boot-th.cabal.in b/libraries/ghc-boot-th/ghc-boot-th.cabal.in
new file mode 100644 (file)
index 0000000..3aebfbf
--- /dev/null
@@ -0,0 +1,37 @@
+-- WARNING: ghc-boot-th.cabal is automatically generated from
+-- ghc-boot-th.cabal.in by ../../configure.  Make sure you are editing
+-- ghc-boot-th.cabal.in, not ghc-boot-th.cabal.
+
+name:           ghc-boot-th
+version:        @ProjectVersionMunged@
+license:        BSD3
+license-file:   LICENSE
+category:       GHC
+maintainer:     ghc-devs@haskell.org
+bug-reports:    https://ghc.haskell.org/trac/ghc/newticket
+synopsis:       Shared functionality between GHC and the @template-haskell@
+                library
+description:    This library contains various bits shared between the @ghc@ and
+                @template-haskell@ libraries.
+                .
+                This package exists to ensure that @template-haskell@ has a
+                minimal set of transitive dependencies, since it is intended to
+                be depended upon by user code.
+cabal-version:  >=1.10
+build-type:     Simple
+extra-source-files: changelog.md
+
+source-repository head
+    type:     git
+    location: http://git.haskell.org/ghc.git
+    subdir:   libraries/ghc-boot-th
+
+Library
+    default-language: Haskell2010
+    other-extensions: DeriveGeneric
+
+    exposed-modules:
+            GHC.LanguageExtensions.Type
+            GHC.Lexeme
+
+    build-depends: base       >= 4.7 && < 4.10
index 7add46e..13c3ec5 100644 (file)
------------------------------------------------------------------------------
--- |
--- Module      :  GHC.LanguageExtensions
--- Copyright   :  (c) The GHC Team
---
--- Maintainer  :  ghc-devs@haskell.org
--- Portability :  portable
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+
+-- | This module re-exports the 'Extension' type along with an orphan 'Binary'
+-- instance for it.
 --
--- A data type defining the language extensions supported by GHC.
+-- Note that the @ghc-boot@ package has a large set of dependencies; for this
+-- reason the 'Extension' type itself is defined in the
+-- "GHC.LanguageExtensions.Type" module provided by the @ghc-boot-th@ package,
+-- which has no dependencies outside of @base@. For this reason
+-- @template-haskell@ depends upon @ghc-boot-th@, not @ghc-boot@.
 --
-{-# LANGUAGE DeriveGeneric #-}
-module GHC.LanguageExtensions ( Extension(..) ) where
+module GHC.LanguageExtensions ( module GHC.LanguageExtensions.Type ) where
 
-import GHC.Generics
 import Data.Binary
-
--- | The language extensions known to GHC.
-data Extension
--- See Note [Updating flag description in the User's Guide] in DynFlags
-   = Cpp
-   | OverlappingInstances
-   | UndecidableInstances
-   | IncoherentInstances
-   | UndecidableSuperClasses
-   | MonomorphismRestriction
-   | MonoPatBinds
-   | MonoLocalBinds
-   | RelaxedPolyRec           -- Deprecated
-   | ExtendedDefaultRules     -- Use GHC's extended rules for defaulting
-   | ForeignFunctionInterface
-   | UnliftedFFITypes
-   | InterruptibleFFI
-   | CApiFFI
-   | GHCForeignImportPrim
-   | JavaScriptFFI
-   | ParallelArrays           -- Syntactic support for parallel arrays
-   | Arrows                   -- Arrow-notation syntax
-   | TemplateHaskell
-   | TemplateHaskellQuotes    -- subset of TH supported by stage1, no splice
-   | QuasiQuotes
-   | ImplicitParams
-   | ImplicitPrelude
-   | ScopedTypeVariables
-   | AllowAmbiguousTypes
-   | UnboxedTuples
-   | BangPatterns
-   | TypeFamilies
-   | TypeFamilyDependencies
-   | TypeInType
-   | OverloadedStrings
-   | OverloadedLists
-   | NumDecimals
-   | DisambiguateRecordFields
-   | RecordWildCards
-   | RecordPuns
-   | ViewPatterns
-   | GADTs
-   | GADTSyntax
-   | NPlusKPatterns
-   | DoAndIfThenElse
-   | RebindableSyntax
-   | ConstraintKinds
-   | PolyKinds                -- Kind polymorphism
-   | DataKinds                -- Datatype promotion
-   | InstanceSigs
-   | ApplicativeDo
-
-   | StandaloneDeriving
-   | DeriveDataTypeable
-   | AutoDeriveTypeable       -- Automatic derivation of Typeable
-   | DeriveFunctor
-   | DeriveTraversable
-   | DeriveFoldable
-   | DeriveGeneric            -- Allow deriving Generic/1
-   | DefaultSignatures        -- Allow extra signatures for defmeths
-   | DeriveAnyClass           -- Allow deriving any class
-   | DeriveLift               -- Allow deriving Lift
-
-   | TypeSynonymInstances
-   | FlexibleContexts
-   | FlexibleInstances
-   | ConstrainedClassMethods
-   | MultiParamTypeClasses
-   | NullaryTypeClasses
-   | FunctionalDependencies
-   | UnicodeSyntax
-   | ExistentialQuantification
-   | MagicHash
-   | EmptyDataDecls
-   | KindSignatures
-   | RoleAnnotations
-   | ParallelListComp
-   | TransformListComp
-   | MonadComprehensions
-   | GeneralizedNewtypeDeriving
-   | RecursiveDo
-   | PostfixOperators
-   | TupleSections
-   | PatternGuards
-   | LiberalTypeSynonyms
-   | RankNTypes
-   | ImpredicativeTypes
-   | TypeOperators
-   | ExplicitNamespaces
-   | PackageImports
-   | ExplicitForAll
-   | AlternativeLayoutRule
-   | AlternativeLayoutRuleTransitional
-   | DatatypeContexts
-   | NondecreasingIndentation
-   | RelaxedLayout
-   | TraditionalRecordSyntax
-   | LambdaCase
-   | MultiWayIf
-   | BinaryLiterals
-   | NegativeLiterals
-   | DuplicateRecordFields
-   | OverloadedLabels
-   | EmptyCase
-   | PatternSynonyms
-   | PartialTypeSignatures
-   | NamedWildCards
-   | StaticPointers
-   | TypeApplications
-   | Strict
-   | StrictData
-   | MonadFailDesugaring
-   deriving (Eq, Enum, Show, Generic)
+import GHC.LanguageExtensions.Type
 
 instance Binary Extension
index e0b4d69..3ed5bbb 100644 (file)
@@ -1,4 +1,4 @@
-## 0.0.0.0  *Feb 2016*
+## 8.0.1  *May 2016*
 
   * Bundled with GHC 8.0.1
 
index b7d3955..eed11e3 100644 (file)
@@ -22,7 +22,7 @@ description:    This library is shared between GHC, ghc-pkg, and other boot
                 The package database format and this library are constructed in
                 such a way that while ghc-pkg depends on Cabal, the GHC library
                 and program do not have to depend on Cabal.
-cabal-version:  >=1.10
+cabal-version:  >=1.22
 build-type:     Simple
 extra-source-files: changelog.md
 
@@ -36,14 +36,17 @@ Library
     other-extensions: DeriveGeneric, RankNTypes, ScopedTypeVariables
 
     exposed-modules:
-            GHC.Lexeme
-            GHC.PackageDb
             GHC.LanguageExtensions
+            GHC.PackageDb
             GHC.Serialized
 
+    reexported-modules:
+            GHC.LanguageExtensions.Type,
+            GHC.Lexeme
+
     build-depends: base       >= 4.7 && < 4.10,
                    binary     == 0.8.*,
                    bytestring == 0.10.*,
                    directory  == 1.2.*,
-                   filepath   >= 1.3 && < 1.5
-
+                   filepath   >= 1.3 && < 1.5,
+                   ghc-boot-th == @ProjectVersionMunged@
index 8a64490..2043e89 100644 (file)
@@ -19,4 +19,4 @@ module Language.Haskell.TH.LanguageExtensions
 -- This module exists primarily to avoid inserting a massive list of language
 -- extensions into the already quite large Haddocks for Language.Haskell.TH
 
-import GHC.LanguageExtensions (Extension(..))
+import GHC.LanguageExtensions.Type (Extension(..))
index 7241708..0d9f468 100644 (file)
@@ -49,9 +49,9 @@ Library
         Language.Haskell.TH.Lib.Map
 
     build-depends:
-        base       >= 4.8 && < 4.10,
-        ghc-boot   == 8.1,
-        pretty     == 1.1.*
+        base        >= 4.8 && < 4.10,
+        ghc-boot-th == 8.1,
+        pretty      == 1.1.*
 
     -- We need to set the unit ID to template-haskell (without a
     -- version number) as it's magic.
index afcac7c..33fec8e 100644 (file)
@@ -4,10 +4,9 @@ TYPE CONSTRUCTORS
   data T (a :: k)
 COERCION AXIOMS
 Dependent modules: []
-Dependent packages: [array-0.5.1.0, base-4.9.0.0, binary-0.8.2.0,
-                     bytestring-0.10.7.0, containers-0.5.7.1, deepseq-1.4.2.0,
-                     ghc-boot-8.1, ghc-prim-0.5.0.0, integer-gmp-1.0.0.1,
-                     pretty-1.1.3.2, template-haskell-2.11.0.0]
+Dependent packages: [array-0.5.1.1, base-4.9.0.0, deepseq-1.4.2.0,
+                     ghc-boot-th-8.1, ghc-prim-0.5.0.0, integer-gmp-1.0.0.1,
+                     pretty-1.1.3.3, template-haskell-2.11.0.0]
 
 ==================== Typechecker ====================
 TH_Roles2.$tcT
index be6828f..1cebbe8 100644 (file)
@@ -287,7 +287,8 @@ test('T8028',
      ['T8028', '-v0 ' + config.ghc_th_way_flags])
 
 test('TH_Roles1', normal, compile_fail, ['-v0'])
-test('TH_Roles2', normalise_version('array', 'base', 'deepseq', 'ghc-prim', 'ghc-boot',
+test('TH_Roles2', normalise_version('array', 'base', 'deepseq', 'ghc-prim',
+                                    'ghc-boot', 'ghc-boot-th',
                                     'integer-gmp', 'pretty', 'template-haskell',
                                     'binary', 'bytestring', 'containers'
                                     ), compile, ['-v0 -ddump-tc'])