aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralexwl <alexey.a.kiryushin@gmail.com>2019-05-17 18:43:42 +0300
committeralexwl <alexey.a.kiryushin@gmail.com>2019-05-17 18:43:42 +0300
commit31267d352e329875e647fa422d68b08106a36cf2 (patch)
tree065465d1b252bf688b91828f26c8be52899decd8
parentfabedd76f04b630b29fdbd680aa56a383441e046 (diff)
Code cleanup: fix warnings
-rw-r--r--app/Indexer.hs2
-rw-r--r--app/Server.hs10
-rw-r--r--app/Store.hs10
-rw-r--r--haskell-code-explorer.cabal1
-rw-r--r--src/HaskellCodeExplorer/AST/RenamedSource.hs10
-rw-r--r--src/HaskellCodeExplorer/AST/TypecheckedSource.hs15
-rw-r--r--src/HaskellCodeExplorer/GhcUtils.hs27
-rw-r--r--src/HaskellCodeExplorer/ModuleInfo.hs12
-rw-r--r--src/HaskellCodeExplorer/PackageInfo.hs27
-rw-r--r--test/Main.hs68
10 files changed, 94 insertions, 88 deletions
diff --git a/app/Indexer.hs b/app/Indexer.hs
index 6284f06..26fad4a 100644
--- a/app/Indexer.hs
+++ b/app/Indexer.hs
@@ -19,7 +19,7 @@ import qualified Data.Serialize as S
import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
import Data.Time (getZonedTime)
-import Data.Version (Version(..),showVersion)
+import Data.Version (showVersion)
import HaskellCodeExplorer.PackageInfo (createPackageInfo, ghcVersion)
import qualified HaskellCodeExplorer.Types as HCE
import Network.URI.Encode (encode)
diff --git a/app/Server.hs b/app/Server.hs
index de2c325..41197b6 100644
--- a/app/Server.hs
+++ b/app/Server.hs
@@ -53,8 +53,6 @@ import Data.Maybe (fromMaybe, mapMaybe)
import qualified Data.Vector as V
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
import qualified GHC.Compact as C
-#else
-import Data.Functor.Identity(Identity(..))
#endif
import Data.Pagination
( Paginated
@@ -139,7 +137,11 @@ import Servant
)
import Servant.API.ContentTypes (AllCTRender(..), JSON)
import Servant.Server (Handler(..), hoistServer)
+#if MIN_VERSION_servant(0,14,1)
+import Servant.Links (safeLink)
+#else
import Servant.Utils.Links (safeLink)
+#endif
import System.Directory (doesFileExist)
import System.Exit (exitFailure, exitSuccess)
import System.FilePath.Find
@@ -751,7 +753,7 @@ loadPackages _config mbStore
eitherGlobalReferenceMap <*>
eitherGlobalIdentifierMap of
Right res -> return $ Just res
- Left _ -> do
+ Left _ -> do
putStrLn "Store lookup errors : "
let ignoreRight :: Either a b -> Either a ()
ignoreRight = second (const ())
@@ -833,7 +835,7 @@ loadPackages config _ = do
filter isExportedId $
trieValues $ HCE.externalIdInfoMap packageInfo
in L.foldl
- (\trie' exportedId@(HCE.ExternalIdentifierInfo (HCE.IdentifierInfo {HCE.demangledOccName = name})) ->
+ (\trie' exportedId@(HCE.ExternalIdentifierInfo HCE.IdentifierInfo {HCE.demangledOccName = name}) ->
HCE.insertToTrie
S.insert
(T.unpack name)
diff --git a/app/Store.hs b/app/Store.hs
index 495f190..15f5736 100644
--- a/app/Store.hs
+++ b/app/Store.hs
@@ -23,7 +23,15 @@ import qualified Data.ByteString as BS
import qualified Data.ByteString.Short as BSS
import Data.Either (Either)
import qualified Data.Map.Strict as M
-import Data.Serialize (Serialize, decode, encode, get, put)
+import Data.Serialize (
+ Serialize,
+ decode,
+ encode,
+#if MIN_VERSION_cereal(0,5,8)
+#else
+ get, put
+#endif
+ )
import GHC.Generics (Generic)
import Prelude hiding (lookup)
import System.Directory (doesFileExist)
diff --git a/haskell-code-explorer.cabal b/haskell-code-explorer.cabal
index 7b40c84..acd90ce 100644
--- a/haskell-code-explorer.cabal
+++ b/haskell-code-explorer.cabal
@@ -53,6 +53,7 @@ library
executable haskell-code-indexer
main-is: Indexer.hs
ghc-options: -Wall -rtsopts -O2 -funbox-strict-fields
+ other-modules: Paths_haskell_code_explorer
hs-source-dirs: app
build-depends: IntervalMap
, aeson
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
diff --git a/test/Main.hs b/test/Main.hs
index 13bbe29..bfe34cd 100644
--- a/test/Main.hs
+++ b/test/Main.hs
@@ -18,7 +18,7 @@ import qualified Data.Set as S
import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
import qualified Data.Vector as V
-import Data.Version
+import Data.Version (makeVersion)
import HaskellCodeExplorer.AST.TypecheckedSource (removeOverlappingInterval)
import HaskellCodeExplorer.PackageInfo
import HaskellCodeExplorer.Preprocessor
@@ -53,7 +53,7 @@ packageInfoSpec currentDir = do
describe "createPackageInfo" $ do
it "returns valid package id" $
HCE.id (packageInfo :: PackageInfo ModuleInfo) `shouldBe`
- PackageId "test-package" (Version [0, 1, 0, 0] [])
+ PackageId "test-package" (makeVersion [0, 1, 0, 0])
it "returns valid list of module paths" $ do
let paths =
HM.fromList
@@ -142,7 +142,7 @@ moduleInfoSpec modInfo =
removeLocationInfo _ = HCE.UnknownLocation ""
removePackageVersionFromExternalId :: HCE.ExternalId -> HCE.ExternalId
removePackageVersionFromExternalId extId@(HCE.ExternalId textId) = case T.splitOn "|" textId of
- packageId:rest -> case T.splitOn "-" packageId of
+ pId:rest -> case T.splitOn "-" pId of
packageIdParts@(_:_) -> HCE.ExternalId $ T.intercalate "|" ((T.intercalate "-" (init packageIdParts)) : rest)
_ -> extId
_ -> extId
@@ -461,11 +461,7 @@ testIdOccMap =
{ packageId =
PackageId
{ name = "test-package"
- , version =
- Version
- { versionBranch = [0, 1, 0, 0]
- , versionTags = []
- }
+ , version = makeVersion [0, 1, 0, 0]
}
, modulePath =
HaskellModulePath
@@ -682,9 +678,7 @@ testIdInfoMap =
{ packageId =
PackageId
{ name = "test-package"
- , version =
- Version
- {versionBranch = [0, 1, 0, 0], versionTags = []}
+ , version = makeVersion [0, 1, 0, 0]
}
, modulePath =
HaskellModulePath {getHaskellModulePath = "src/Lib.hs"}
@@ -729,9 +723,7 @@ testIdInfoMap =
{ packageId =
PackageId
{ name = "ghc-prim"
- , version =
- Version
- {versionBranch = [0, 5, 1, 1], versionTags = []}
+ , version = makeVersion [0, 5, 1, 1]
}
, moduleName =
HaskellModuleName {getHaskellModuleName = "GHC.Prim"}
@@ -771,9 +763,7 @@ testIdInfoMap =
{ packageId =
PackageId
{ name = "ghc-prim"
- , version =
- Version
- {versionBranch = [0, 5, 1, 1], versionTags = []}
+ , version = makeVersion [0, 5, 1, 1]
}
, moduleName =
HaskellModuleName {getHaskellModuleName = "GHC.Types"}
@@ -804,9 +794,7 @@ testIdInfoMap =
{ packageId =
PackageId
{ name = "test-package"
- , version =
- Version
- {versionBranch = [0, 1, 0, 0], versionTags = []}
+ , version = makeVersion [0, 1, 0, 0]
}
, modulePath =
HaskellModulePath {getHaskellModulePath = "src/Types.hs"}
@@ -852,9 +840,7 @@ testIdInfoMap =
{ packageId =
PackageId
{ name = "ghc-prim"
- , version =
- Version
- {versionBranch = [0, 5, 1, 1], versionTags = []}
+ , version = makeVersion [0, 5, 1, 1]
}
, moduleName =
HaskellModuleName {getHaskellModuleName = "GHC.Types"}
@@ -885,9 +871,7 @@ testIdInfoMap =
{ packageId =
PackageId
{ name = "test-package"
- , version =
- Version
- {versionBranch = [0, 1, 0, 0], versionTags = []}
+ , version = makeVersion [0, 1, 0, 0]
}
, modulePath =
HaskellModulePath {getHaskellModulePath = "src/Types.hs"}
@@ -920,9 +904,7 @@ testIdInfoMap =
{ packageId =
PackageId
{ name = "ghc-prim"
- , version =
- Version
- {versionBranch = [0, 5, 1, 1], versionTags = []}
+ , version = makeVersion [0, 5, 1, 1]
}
, moduleName =
HaskellModuleName {getHaskellModuleName = "GHC.Types"}
@@ -961,9 +943,7 @@ testIdInfoMap =
{ packageId =
PackageId
{ name = "ghc-prim"
- , version =
- Version
- {versionBranch = [0, 5, 1, 1], versionTags = []}
+ , version = makeVersion [0, 5, 1, 1]
}
, moduleName =
HaskellModuleName {getHaskellModuleName = "GHC.Tuple"}
@@ -994,9 +974,7 @@ testIdInfoMap =
{ packageId =
PackageId
{ name = "base"
- , version =
- Version
- {versionBranch = [4, 10, 1, 0], versionTags = []}
+ , version = makeVersion [4, 10, 1, 0]
}
, moduleName =
HaskellModuleName {getHaskellModuleName = "GHC.Base"}
@@ -1027,9 +1005,7 @@ testIdInfoMap =
{ packageId =
PackageId
{ name = "test-package"
- , version =
- Version
- {versionBranch = [0, 1, 0, 0], versionTags = []}
+ , version = makeVersion [0, 1, 0, 0]
}
, modulePath =
HaskellModulePath {getHaskellModulePath = "src/Lib.hs"}
@@ -1070,9 +1046,7 @@ testIdInfoMap =
{ packageId =
PackageId
{ name = "base"
- , version =
- Version
- {versionBranch = [4, 10, 1, 0], versionTags = []}
+ , version = makeVersion [4, 10, 1, 0]
}
, moduleName =
HaskellModuleName {getHaskellModuleName = "System.IO"}
@@ -1130,9 +1104,7 @@ testIdInfoMap =
{ packageId =
PackageId
{ name = "ghc-prim"
- , version =
- Version
- {versionBranch = [0, 5, 1, 1], versionTags = []}
+ , version = makeVersion [0, 5, 1, 1]
}
, moduleName =
HaskellModuleName {getHaskellModuleName = "GHC.Types"}
@@ -1163,9 +1135,7 @@ testIdInfoMap =
{ packageId =
PackageId
{ name = "ghc-prim"
- , version =
- Version
- {versionBranch = [0, 5, 1, 1], versionTags = []}
+ , version = makeVersion [0, 5, 1, 1]
}
, moduleName =
HaskellModuleName {getHaskellModuleName = "GHC.Types"}
@@ -1196,9 +1166,7 @@ testIdInfoMap =
{ packageId =
PackageId
{ name = "test-package"
- , version =
- Version
- {versionBranch = [0, 1, 0, 0], versionTags = []}
+ , version = makeVersion [0, 1, 0, 0]
}
, modulePath =
HaskellModulePath {getHaskellModulePath = "src/Lib.hs"}