diff options
Diffstat (limited to 'compiler/GHC/Unit')
-rw-r--r-- | compiler/GHC/Unit/Home.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/Unit/Module.hs | 5 | ||||
-rw-r--r-- | compiler/GHC/Unit/Module/Deps.hs | 1 | ||||
-rw-r--r-- | compiler/GHC/Unit/Module/Env.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/Unit/Module/Name.hs | 98 | ||||
-rw-r--r-- | compiler/GHC/Unit/Parser.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Unit/Types.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Unit/Types.hs-boot | 2 |
8 files changed, 11 insertions, 107 deletions
diff --git a/compiler/GHC/Unit/Home.hs b/compiler/GHC/Unit/Home.hs index c72d21e537..4f871d10fb 100644 --- a/compiler/GHC/Unit/Home.hs +++ b/compiler/GHC/Unit/Home.hs @@ -33,9 +33,10 @@ where import GHC.Prelude import GHC.Unit.Types -import GHC.Unit.Module.Name import Data.Maybe +import Language.Haskell.Syntax.Module.Name + -- | Information about the home unit (i.e., the until that will contain the -- modules we are compiling) -- diff --git a/compiler/GHC/Unit/Module.hs b/compiler/GHC/Unit/Module.hs index b9813b95f5..7ae0059b71 100644 --- a/compiler/GHC/Unit/Module.hs +++ b/compiler/GHC/Unit/Module.hs @@ -18,7 +18,7 @@ module GHC.Unit.Module ( module GHC.Unit.Types -- * The ModuleName type - , module GHC.Unit.Module.Name + , module Language.Haskell.Syntax.Module.Name -- * The ModLocation type , module GHC.Unit.Module.Location @@ -47,11 +47,12 @@ import GHC.Prelude import GHC.Types.Unique.DSet import GHC.Unit.Types -import GHC.Unit.Module.Name import GHC.Unit.Module.Location import GHC.Unit.Module.Env import GHC.Utils.Misc +import Language.Haskell.Syntax.Module.Name + -- | A 'Module' is definite if it has no free holes. moduleIsDefinite :: Module -> Bool moduleIsDefinite = isEmptyUniqDSet . moduleFreeHoles diff --git a/compiler/GHC/Unit/Module/Deps.hs b/compiler/GHC/Unit/Module/Deps.hs index 5a50f42b35..9099ee2f0d 100644 --- a/compiler/GHC/Unit/Module/Deps.hs +++ b/compiler/GHC/Unit/Module/Deps.hs @@ -24,7 +24,6 @@ import GHC.Prelude import GHC.Types.SafeHaskell import GHC.Types.Name -import GHC.Unit.Module.Name import GHC.Unit.Module.Imported import GHC.Unit.Module import GHC.Unit.Home diff --git a/compiler/GHC/Unit/Module/Env.hs b/compiler/GHC/Unit/Module/Env.hs index e8307229f7..32ca0b12cd 100644 --- a/compiler/GHC/Unit/Module/Env.hs +++ b/compiler/GHC/Unit/Module/Env.hs @@ -37,7 +37,6 @@ where import GHC.Prelude -import GHC.Unit.Module.Name (ModuleName) import GHC.Types.Unique import GHC.Types.Unique.FM import GHC.Types.Unique.DFM @@ -54,6 +53,8 @@ import qualified Data.Set as Set import qualified GHC.Data.FiniteMap as Map import GHC.Utils.Outputable +import Language.Haskell.Syntax.Module.Name + -- | A map keyed off of 'Module's newtype ModuleEnv elt = ModuleEnv (Map NDModule elt) diff --git a/compiler/GHC/Unit/Module/Name.hs b/compiler/GHC/Unit/Module/Name.hs deleted file mode 100644 index b7bf62857c..0000000000 --- a/compiler/GHC/Unit/Module/Name.hs +++ /dev/null @@ -1,98 +0,0 @@ -{-# OPTIONS_GHC -Wno-orphans #-} -- Outputable and Module Name - --- | The ModuleName type -module GHC.Unit.Module.Name - ( ModuleName - , pprModuleName - , moduleNameFS - , moduleNameString - , moduleNameSlashes, moduleNameColons - , mkModuleName - , mkModuleNameFS - , stableModuleNameCmp - , parseModuleName - ) -where - -import {-# SOURCE #-} Language.Haskell.Syntax.ImpExp (ModuleName(..)) - -import GHC.Prelude - -import GHC.Utils.Outputable -import GHC.Types.Unique -import GHC.Data.FastString -import GHC.Utils.Binary -import GHC.Utils.Misc - -import Control.DeepSeq -import Data.Data -import System.FilePath - -import qualified Text.ParserCombinators.ReadP as Parse -import Text.ParserCombinators.ReadP (ReadP) -import Data.Char (isAlphaNum) - -instance Uniquable ModuleName where - getUnique (ModuleName nm) = getUnique nm - -instance Eq ModuleName where - nm1 == nm2 = getUnique nm1 == getUnique nm2 - -instance Ord ModuleName where - nm1 `compare` nm2 = stableModuleNameCmp nm1 nm2 - -instance Outputable ModuleName where - ppr = pprModuleName - -instance Binary ModuleName where - put_ bh (ModuleName fs) = put_ bh fs - get bh = do fs <- get bh; return (ModuleName fs) - -instance Data ModuleName where - -- don't traverse? - toConstr _ = abstractConstr "ModuleName" - gunfold _ _ = error "gunfold" - dataTypeOf _ = mkNoRepType "ModuleName" - -instance NFData ModuleName where - rnf x = x `seq` () - -stableModuleNameCmp :: ModuleName -> ModuleName -> Ordering --- ^ Compares module names lexically, rather than by their 'Unique's -stableModuleNameCmp n1 n2 = moduleNameFS n1 `lexicalCompareFS` moduleNameFS n2 - -pprModuleName :: ModuleName -> SDoc -pprModuleName (ModuleName nm) = - getPprStyle $ \ sty -> - if codeStyle sty - then ztext (zEncodeFS nm) - else ftext nm - -moduleNameFS :: ModuleName -> FastString -moduleNameFS (ModuleName mod) = mod - -moduleNameString :: ModuleName -> String -moduleNameString (ModuleName mod) = unpackFS mod - -mkModuleName :: String -> ModuleName -mkModuleName s = ModuleName (mkFastString s) - -mkModuleNameFS :: FastString -> ModuleName -mkModuleNameFS s = ModuleName s - --- |Returns the string version of the module name, with dots replaced by slashes. --- -moduleNameSlashes :: ModuleName -> String -moduleNameSlashes = dots_to_slashes . moduleNameString - where dots_to_slashes = map (\c -> if c == '.' then pathSeparator else c) - --- |Returns the string version of the module name, with dots replaced by colons. --- -moduleNameColons :: ModuleName -> String -moduleNameColons = dots_to_colons . moduleNameString - where dots_to_colons = map (\c -> if c == '.' then ':' else c) - -parseModuleName :: ReadP ModuleName -parseModuleName = fmap mkModuleName - $ Parse.munch1 (\c -> isAlphaNum c || c `elem` "_.") - diff --git a/compiler/GHC/Unit/Parser.hs b/compiler/GHC/Unit/Parser.hs index f9735306de..bac6ba4bf1 100644 --- a/compiler/GHC/Unit/Parser.hs +++ b/compiler/GHC/Unit/Parser.hs @@ -10,13 +10,14 @@ where import GHC.Prelude import GHC.Unit.Types -import GHC.Unit.Module.Name import GHC.Data.FastString import qualified Text.ParserCombinators.ReadP as Parse import Text.ParserCombinators.ReadP (ReadP, (<++)) import Data.Char (isAlphaNum) +import Language.Haskell.Syntax.Module.Name (ModuleName, parseModuleName) + parseUnit :: ReadP Unit parseUnit = parseVirtUnitId <++ parseDefUnitId where @@ -55,4 +56,3 @@ parseModSubst = Parse.between (Parse.char '[') (Parse.char ']') v <- parseHoleyModule return (k, v) - diff --git a/compiler/GHC/Unit/Types.hs b/compiler/GHC/Unit/Types.hs index e99fea94d4..f71ce9c02e 100644 --- a/compiler/GHC/Unit/Types.hs +++ b/compiler/GHC/Unit/Types.hs @@ -91,7 +91,6 @@ where import GHC.Prelude import GHC.Types.Unique import GHC.Types.Unique.DSet -import GHC.Unit.Module.Name import GHC.Utils.Binary import GHC.Utils.Outputable import GHC.Data.FastString @@ -107,6 +106,7 @@ import Data.Bifunctor import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as BS.Char8 +import Language.Haskell.Syntax.Module.Name import {-# SOURCE #-} Language.Haskell.Syntax.ImpExp (IsBootInterface(..)) --------------------------------------------------------------------- diff --git a/compiler/GHC/Unit/Types.hs-boot b/compiler/GHC/Unit/Types.hs-boot index 21a0f6bc79..a7e09126d5 100644 --- a/compiler/GHC/Unit/Types.hs-boot +++ b/compiler/GHC/Unit/Types.hs-boot @@ -3,7 +3,7 @@ module GHC.Unit.Types where import GHC.Prelude () import {-# SOURCE #-} GHC.Utils.Outputable -import {-# SOURCE #-} Language.Haskell.Syntax.ImpExp ( ModuleName ) +import Language.Haskell.Syntax.Module.Name (ModuleName) import Data.Kind (Type) data UnitId |