diff options
author | alexwl <alexey.a.kiryushin@gmail.com> | 2019-05-17 18:43:42 +0300 |
---|---|---|
committer | alexwl <alexey.a.kiryushin@gmail.com> | 2019-05-17 18:43:42 +0300 |
commit | 31267d352e329875e647fa422d68b08106a36cf2 (patch) | |
tree | 065465d1b252bf688b91828f26c8be52899decd8 /src/HaskellCodeExplorer | |
parent | fabedd76f04b630b29fdbd680aa56a383441e046 (diff) |
Code cleanup: fix warnings
Diffstat (limited to 'src/HaskellCodeExplorer')
-rw-r--r-- | src/HaskellCodeExplorer/AST/RenamedSource.hs | 10 | ||||
-rw-r--r-- | src/HaskellCodeExplorer/AST/TypecheckedSource.hs | 15 | ||||
-rw-r--r-- | src/HaskellCodeExplorer/GhcUtils.hs | 27 | ||||
-rw-r--r-- | src/HaskellCodeExplorer/ModuleInfo.hs | 12 | ||||
-rw-r--r-- | src/HaskellCodeExplorer/PackageInfo.hs | 27 |
5 files changed, 59 insertions, 32 deletions
diff --git a/src/HaskellCodeExplorer/AST/RenamedSource.hs b/src/HaskellCodeExplorer/AST/RenamedSource.hs index 90f9ceb..68aeddb 100644 --- a/src/HaskellCodeExplorer/AST/RenamedSource.hs +++ b/src/HaskellCodeExplorer/AST/RenamedSource.hs @@ -18,7 +18,10 @@ import GHC ( AmbiguousFieldOcc(..) , ConDecl(..) , ConDeclField(..) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#else , DataFamInstDecl(..) +#endif , FamilyDecl(..) , FieldOcc(..) , FixitySig(..) @@ -26,7 +29,11 @@ import GHC , GenLocated(..) , HsBindLR(..) , HsExpr(..) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,1,0) + , HsPatSynDetails +#else , HsPatSynDetails(..) +#endif , HsRecField'(..) , HsTupleSort(..) , HsTyLit(..) @@ -36,7 +43,10 @@ import GHC , IE(..) , LHsBindLR , LHsExpr +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#else , LHsQTyVars(..) +#endif , LHsType , LPat , LSig diff --git a/src/HaskellCodeExplorer/AST/TypecheckedSource.hs b/src/HaskellCodeExplorer/AST/TypecheckedSource.hs index 02f406b..50ab061 100644 --- a/src/HaskellCodeExplorer/AST/TypecheckedSource.hs +++ b/src/HaskellCodeExplorer/AST/TypecheckedSource.hs @@ -20,7 +20,11 @@ module HaskellCodeExplorer.AST.TypecheckedSource import Bag (bagToList) import BasicTypes (Origin(..)) import Class (Class, classTyVars) -import ConLike (ConLike(..),conLikeWrapId_maybe) +import ConLike (ConLike(..) +#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) + , conLikeWrapId_maybe +#endif + ) import Control.Monad (return, unless, void) import Control.Monad.State.Strict (State, get, modify') import qualified Data.HashMap.Strict as HM @@ -35,7 +39,12 @@ import DynFlags (DynFlags) import FastString (mkFastString) import HaskellCodeExplorer.GhcUtils import qualified HaskellCodeExplorer.Types as HCE -import HsBinds (HsPatSynDetails(..), RecordPatSynField(..)) +import HsBinds (RecordPatSynField(..) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#else + , HsPatSynDetails (..) +#endif + ) import HsSyn ( ABExport(..) , ApplicativeArg(..) @@ -175,7 +184,7 @@ data Environment = Environment -- | Indicates whether an expression consists of more than one token. -- Simple expression : wildcard, literal --- Composite expressin : applcation, lambda abstraction,... +-- Composite expression : application, lambda abstraction,... data ExprSort = Simple | Composite diff --git a/src/HaskellCodeExplorer/GhcUtils.hs b/src/HaskellCodeExplorer/GhcUtils.hs index 3ac1f86..031f411 100644 --- a/src/HaskellCodeExplorer/GhcUtils.hs +++ b/src/HaskellCodeExplorer/GhcUtils.hs @@ -74,16 +74,17 @@ import DataCon (dataConWorkId, flSelector) import Documentation.Haddock.Parser (overIdentifier, parseParas) import Documentation.Haddock.Types (DocH(..), Header(..), - _doc, -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) - Table(..) -#endif + _doc ) import DynFlags () import FastString (mkFastString, unpackFS) import GHC ( DynFlags - , HsDocString(..) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) + , HsDocString +#else + , HsDocString (..) +#endif , InstDecl(..) , ModuleName , Name @@ -97,7 +98,11 @@ import GHC , HsGroup(..) , HsBindLR(..) , HsValBindsLR(..) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,1,0) + , HsPatSynDetails +#else , HsPatSynDetails(..) +#endif , Located , IE(..) , TyThing(..) @@ -687,12 +692,12 @@ nameLocationInfo flags currentPackageId compId transformation fileMap defSiteMap Nothing -> approximateLocation where realSrcSpan :: Name -> Maybe SrcSpan -> Maybe RealSrcSpan - realSrcSpan name mbSrcSpan = - case nameSrcSpan name of + realSrcSpan n mbSpan = + case nameSrcSpan n of RealSrcSpan span -> Just span _ - | isWiredInName name -> - case mbSrcSpan of + | isWiredInName n -> + case mbSpan of Just span -> case span of RealSrcSpan s -> Just s @@ -1082,9 +1087,9 @@ ungroup group_ = #endif typesigs _ = [] #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) - valbinds (XValBindsLR (NValBinds binds _)) = concatMap bagToList . snd . unzip $ binds + valbinds (XValBindsLR (NValBinds binds _)) = concatMap (bagToList . snd) binds #else - valbinds (ValBindsOut binds _) = concatMap bagToList . snd . unzip $ binds + valbinds (ValBindsOut binds _) = concatMap (bagToList . snd) binds #endif valbinds _ = [] diff --git a/src/HaskellCodeExplorer/ModuleInfo.hs b/src/HaskellCodeExplorer/ModuleInfo.hs index a97d758..f449eee 100644 --- a/src/HaskellCodeExplorer/ModuleInfo.hs +++ b/src/HaskellCodeExplorer/ModuleInfo.hs @@ -63,20 +63,24 @@ import HaskellCodeExplorer.AST.TypecheckedSource import HaskellCodeExplorer.GhcUtils import HaskellCodeExplorer.Preprocessor (createSourceCodeTransformation) import qualified HaskellCodeExplorer.Types as HCE -import HsBinds(HsBindLR) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +import HsBinds (HsBindLR) +#endif import HsDecls ( ForeignDecl(..) , HsDecl(..) , HsGroup(..) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) , InstDecl - , InstDecl(..) , TyClDecl +#endif + , InstDecl(..) , group_tyclds , tyClDeclLName , tcdName #if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) , hsGroupInstDecls -#endif +#endif ) import HsDoc(HsDocString) import HsImpExp (IE(..), ImportDecl(..)) @@ -503,7 +507,7 @@ createDeclarations flags hsGroup typeEnv exportedSet transformation = Nothing -> Nothing -- | Top-level functions -------------------------------------------------------------------------------- -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) valToDeclarations :: GenLocated SrcSpan (HsBindLR GhcRn GhcRn) -> [HCE.Declaration] #endif valToDeclarations (L loc bind) = diff --git a/src/HaskellCodeExplorer/PackageInfo.hs b/src/HaskellCodeExplorer/PackageInfo.hs index 91028af..07f974e 100644 --- a/src/HaskellCodeExplorer/PackageInfo.hs +++ b/src/HaskellCodeExplorer/PackageInfo.hs @@ -22,7 +22,7 @@ import Control.Exception , throw , try ) -import Control.Monad (foldM, join, unless) +import Control.Monad (foldM, unless) import Control.Monad.Extra (anyM, findM) import Control.Monad.Logger ( LoggingT(..) @@ -41,7 +41,7 @@ import Data.Maybe (fromMaybe, isJust, maybeToList) import qualified Data.Set as S import qualified Data.Text as T import qualified Data.Text.Encoding as TE -import Data.Version (Version(..), showVersion) +import Data.Version (Version(..), showVersion, makeVersion) import Digraph (flattenSCCs) import Distribution.Helper ( ChComponentName(..) @@ -118,7 +118,7 @@ import System.FilePath , takeDirectory , splitDirectories ) -import System.FilePath.Find +import System.FilePath.Find (find,always,(==?),fileName) import System.Process (readProcess) createPackageInfo :: @@ -268,26 +268,26 @@ createPackageInfo packageDirectoryPath mbDistDirRelativePath sourceCodePreproces #if MIN_VERSION_GLASGOW_HASKELL(8,6,5,0) ghcVersion :: Version -ghcVersion = Version {versionBranch = [8, 6, 5, 0], versionTags = []} +ghcVersion = makeVersion [8, 6, 5, 0] #elif MIN_VERSION_GLASGOW_HASKELL(8,6,4,0) ghcVersion :: Version -ghcVersion = Version {versionBranch = [8, 6, 4, 0], versionTags = []} +ghcVersion = makeVersion [8, 6, 4, 0] #elif MIN_VERSION_GLASGOW_HASKELL(8,6,3,0) ghcVersion :: Version -ghcVersion = Version {versionBranch = [8, 6, 3, 0], versionTags = []} +ghcVersion = makeVersion [8, 6, 3, 0] #elif MIN_VERSION_GLASGOW_HASKELL(8,4,4,0) ghcVersion :: Version -ghcVersion = Version {versionBranch = [8, 4, 4, 0], versionTags = []} +ghcVersion = makeVersion [8, 4, 4, 0] #elif MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) ghcVersion :: Version -ghcVersion = Version {versionBranch = [8, 4, 3, 0], versionTags = []} +ghcVersion = makeVersion [8, 4, 3, 0] #elif MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) ghcVersion :: Version -ghcVersion = Version {versionBranch = [8, 2, 2, 0], versionTags = []} +ghcVersion = makeVersion [8, 2, 2, 0] #else ghcVersion :: Version -ghcVersion = Version {versionBranch = [8, 0, 2, 0], versionTags = []} -#endif +ghcVersion = makeVersion [8, 0, 2, 0] +#endif buildDirectoryTree :: FilePath -> [FilePath] -> (FilePath -> Bool) -> IO HCE.DirTree buildDirectoryTree path ignoreDirectories isHaskellModule = do @@ -340,8 +340,7 @@ addReferencesFromModule references modInfo@HCE.ModuleInfo {..} = modInfo (\occMap lineNumber startCol endCol occ -> let mbIdExternalId = - join $ - HCE.externalId <$> + HCE.externalId =<< maybe Nothing (`HM.lookup` idInfoMap) @@ -480,7 +479,7 @@ indexBuildComponent sourceCodePreprocessing currentPackageId componentId deps@(f logDebugN (T.append "Modules : " $ T.pack $ show modules) logDebugN (T.append "GHC command line options : " $ - T.pack $ L.intercalate " " (options ++ modules)) + T.pack $ L.unwords (options ++ modules)) flags <- getSessionDynFlags (flags', _, _) <- parseDynamicFlagsCmdLine |