Skip to content

Commit

Permalink
Eliminate GHC/Util/Module
Browse files Browse the repository at this point in the history
  • Loading branch information
shayne-fletcher committed May 31, 2020
1 parent 82d74f0 commit b93e34c
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 24 deletions.
3 changes: 1 addition & 2 deletions hlint.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ library
build-depends:
ghc-lib-parser == 8.10.*
build-depends:
ghc-lib-parser-ex >= 8.10.0.11 && < 8.10.1
ghc-lib-parser-ex >= 8.10.0.13 && < 8.10.1

if flag(gpl)
build-depends: hscolour >= 1.21
Expand Down Expand Up @@ -116,7 +116,6 @@ library
GHC.Util.FreeVars
GHC.Util.HsDecl
GHC.Util.HsExpr
GHC.Util.Module
GHC.Util.SrcLoc
GHC.Util.DynFlags
GHC.Util.Scope
Expand Down
7 changes: 4 additions & 3 deletions src/Apply.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import Data.Maybe
import Data.Ord
import Config.Type
import Config.Haskell
import SrcLoc
import GHC.Hs
import qualified SrcLoc as GHC
import Language.Haskell.GhclibParserEx.GHC.Hs
import qualified Data.HashSet as Set
import Prelude

Expand Down Expand Up @@ -51,7 +52,7 @@ applyHintsReal :: [Setting] -> Hint -> [ModuleEx] -> [Idea]
applyHintsReal settings hints_ ms = concat $
[ map (classify classifiers . removeRequiresExtensionNotes m) $
order [] (hintModule hints settings nm m) `merge`
concat [order (maybeToList $ declName d) $ decHints d | d <- hsmodDecls $ GHC.unLoc $ ghcModule m]
concat [order (maybeToList $ declName d) $ decHints d | d <- hsmodDecls $ unLoc $ ghcModule m]
| (nm,m) <- mns
, let classifiers = cls ++ mapMaybe readPragma (universeBi (ghcModule m)) ++ concatMap readComment (ghcComments m)
, seq (length classifiers) True -- to force any errors from readPragma or readComment
Expand All @@ -62,7 +63,7 @@ applyHintsReal settings hints_ ms = concat $
where
f = nubOrd . filter (/= "")
cls = [x | SettingClassify x <- settings]
mns = map (\x -> (scopeCreate (GHC.unLoc $ ghcModule x), x)) ms
mns = map (\x -> (scopeCreate (unLoc $ ghcModule x), x)) ms
hints = (if length ms <= 1 then noModules else id) hints_
noModules h = h{hintModules = \_ _ -> []} `mappend` mempty{hintModule = \s a b -> hintModules h s [(a,b)]}

Expand Down
2 changes: 0 additions & 2 deletions src/GHC/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module GHC.Util (
, module GHC.Util.ApiAnnotation
, module GHC.Util.HsDecl
, module GHC.Util.HsExpr
, module GHC.Util.Module
, module GHC.Util.SrcLoc
, module GHC.Util.DynFlags
, module GHC.Util.Scope
Expand All @@ -24,7 +23,6 @@ import GHC.Util.FreeVars
import GHC.Util.ApiAnnotation
import GHC.Util.HsExpr
import GHC.Util.HsDecl
import GHC.Util.Module
import GHC.Util.SrcLoc
import GHC.Util.DynFlags
import GHC.Util.Scope
Expand Down
13 changes: 0 additions & 13 deletions src/GHC/Util/Module.hs

This file was deleted.

3 changes: 1 addition & 2 deletions src/GHC/Util/Scope.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import FastString
import RdrName
import OccName

import GHC.Util.Module
import Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader
import Language.Haskell.GhclibParserEx.GHC.Utils.Outputable

Expand Down Expand Up @@ -47,7 +46,7 @@ scopeCreate xs = Scope $ [prelude | not $ any isPrelude res] ++ res

-- Predicate to test for a 'Prelude' import declaration.
isPrelude :: LImportDecl GhcPs -> Bool
isPrelude (L _ x) = fromModuleName' (ideclName x) == "Prelude"
isPrelude (L _ x) = moduleNameString (unLoc (ideclName x)) == "Prelude"

-- Test if two names in two scopes may be referring to the same
-- thing. This is the case if the names are equal and (1) denote a
Expand Down
1 change: 1 addition & 0 deletions src/Hint/Duplicate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import GHC.Hs
import Outputable
import Bag
import GHC.Util
import Language.Haskell.GhclibParserEx.GHC.Hs
import Language.Haskell.GhclibParserEx.GHC.Hs.ExtendInstances
import Language.Haskell.GhclibParserEx.GHC.Utils.Outputable

Expand Down
1 change: 1 addition & 0 deletions src/Hint/Restrict.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import ApiAnnotation
import Module
import SrcLoc
import OccName
import Language.Haskell.GhclibParserEx.GHC.Hs
import Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader
import GHC.Util

Expand Down
4 changes: 2 additions & 2 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ packages:
- .
extra-deps:
- ghc-lib-parser-8.10.1.20200523
- ghc-lib-parser-ex-8.10.0.11
- ghc-lib-parser-ex-8.10.0.13
# To test hlint against experimental builds of ghc-lib-parser-ex,
# modify extra-deps like this:
# - archive: /users/shaynefletcher/project/ghc-lib-parser-ex.git/ghc-lib-parser-ex-8.10.0.11.tar.gz
# - archive: /users/shaynefletcher/project/ghc-lib-parser-ex.git/ghc-lib-parser-ex-8.10.0.14.tar.gz
# sha256: "0000000000000000000000000000000000000000000000000000000000000000"
- extra-1.7.3
ghc-options: {"$locals": -ddump-to-file -ddump-hi -Werror=unused-imports -Werror=unused-top-binds -Werror=orphans}
Expand Down

0 comments on commit b93e34c

Please sign in to comment.