From 82c8555daa1872af08876b74563022c67ec87abd Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Fri, 24 Jan 2020 16:49:00 -0500 Subject: [PATCH] Nuke the File type alias. --- src/Data/Blob.hs | 6 +----- src/Data/Project.hs | 4 ++-- src/Semantic/Api/LegacyTypes.hs | 2 +- src/Semantic/Api/Symbols.hs | 2 +- src/Semantic/CLI.hs | 3 +-- src/Semantic/Graph.hs | 1 + src/Semantic/Task/Files.hs | 11 ++++++----- 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/Data/Blob.hs b/src/Data/Blob.hs index a5e2dec69..6e09e233e 100644 --- a/src/Data/Blob.hs +++ b/src/Data/Blob.hs @@ -6,11 +6,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} module Data.Blob -( File -, Analysis.File.fileBody -, Analysis.File.filePath -, Analysis.File.fromPath -, Blob(..) +( Blob(..) , Blobs(..) , blobLanguage , NoLanguageForBlob (..) diff --git a/src/Data/Project.hs b/src/Data/Project.hs index 2384c558e..fd761c44c 100644 --- a/src/Data/Project.hs +++ b/src/Data/Project.hs @@ -9,7 +9,7 @@ module Data.Project import Prelude hiding (readFile) import Prologue -import qualified Analysis.File +import Analysis.File import Data.Blob import Data.Blob.IO import Data.Language @@ -33,7 +33,7 @@ projectName = T.pack . dropExtensions . takeFileName . projectRootDir projectExtensions :: Project -> [String] projectExtensions = extensionsForLanguage . projectLanguage -projectFiles :: Project -> [File] +projectFiles :: Project -> [File Language] projectFiles = fmap blobFile . projectBlobs readProjectFromPaths :: MonadIO m diff --git a/src/Semantic/Api/LegacyTypes.hs b/src/Semantic/Api/LegacyTypes.hs index 05d15e1de..417d097f7 100644 --- a/src/Semantic/Api/LegacyTypes.hs +++ b/src/Semantic/Api/LegacyTypes.hs @@ -15,7 +15,7 @@ module Semantic.Api.LegacyTypes ) where import Data.Aeson -import Data.Blob hiding (File) +import Data.Blob import Prologue newtype DiffTreeRequest = DiffTreeRequest { blobs :: [BlobPair] } diff --git a/src/Semantic/Api/Symbols.hs b/src/Semantic/Api/Symbols.hs index e17b30af3..0146cfa65 100644 --- a/src/Semantic/Api/Symbols.hs +++ b/src/Semantic/Api/Symbols.hs @@ -22,7 +22,7 @@ import Control.Effect.Reader import Control.Exception import Control.Lens import Data.Abstract.Declarations -import Data.Blob hiding (File) +import Data.Blob import Data.ByteString.Builder import Data.Language import Data.ProtoLens (defMessage) diff --git a/src/Semantic/CLI.hs b/src/Semantic/CLI.hs index bf1e95c0a..de9331ca5 100644 --- a/src/Semantic/CLI.hs +++ b/src/Semantic/CLI.hs @@ -5,7 +5,6 @@ module Semantic.CLI (main) where import qualified Analysis.File as File import qualified Control.Carrier.Parse.Measured as Parse import Control.Carrier.Reader -import Data.Blob import Data.Blob.IO import Data.Either import qualified Data.Flag as Flag @@ -186,7 +185,7 @@ languageModes = Language.PerLanguageModes <> value Language.ALaCarte <> showDefault) -filePathReader :: ReadM File +filePathReader :: ReadM (File.File Language.Language) filePathReader = File.fromPath <$> path path :: (Path.PartClass.FileDir fd) => ReadM (Path.AbsRel fd) diff --git a/src/Semantic/Graph.hs b/src/Semantic/Graph.hs index 50c871c51..5d36c2604 100644 --- a/src/Semantic/Graph.hs +++ b/src/Semantic/Graph.hs @@ -43,6 +43,7 @@ import Prelude hiding (readFile) import Analysis.Abstract.Caching.FlowInsensitive import Analysis.Abstract.Collecting import Analysis.Abstract.Graph as Graph +import Analysis.File import Control.Abstract hiding (String) import Control.Abstract.PythonPackage as PythonPackage import Control.Algebra diff --git a/src/Semantic/Task/Files.hs b/src/Semantic/Task/Files.hs index 5065d101c..7573c6cd3 100644 --- a/src/Semantic/Task/Files.hs +++ b/src/Semantic/Task/Files.hs @@ -27,6 +27,7 @@ module Semantic.Task.Files , FilesArg(..) ) where +import Analysis.File import Control.Algebra import Control.Effect.Error import Data.Blob @@ -43,10 +44,10 @@ import qualified System.Path as Path import qualified System.Path.IO as IO (withBinaryFile) data Source blob where - FromPath :: File -> Source Blob + FromPath :: File Language -> Source Blob FromHandle :: Handle 'IO.ReadMode -> Source [Blob] FromDir :: Path.AbsRelDir -> Source [Blob] - FromPathPair :: File -> File -> Source BlobPair + FromPathPair :: File Language -> File Language -> Source BlobPair FromPairHandle :: Handle 'IO.ReadMode -> Source [BlobPair] data Destination = ToPath Path.AbsRelFile | ToHandle (Handle 'IO.WriteMode) @@ -92,13 +93,13 @@ instance (Has (Error SomeException) sig m, MonadFail m, MonadIO m) => Algebra (F Write (ToPath path) builder k -> liftIO (IO.withBinaryFile path IO.WriteMode (`B.hPutBuilder` builder)) >> k Write (ToHandle (WriteHandle handle)) builder k -> liftIO (B.hPutBuilder handle builder) >> k -readBlob :: Has Files sig m => File -> m Blob +readBlob :: Has Files sig m => File Language -> m Blob readBlob file = send (Read (FromPath file) pure) -- Various ways to read in files data FilesArg = FilesFromHandle (Handle 'IO.ReadMode) - | FilesFromPaths [File] + | FilesFromPaths [File Language] -- | A task which reads a list of 'Blob's from a 'Handle' or a list of 'FilePath's optionally paired with 'Language's. readBlobs :: Has Files sig m => FilesArg -> m [Blob] @@ -106,7 +107,7 @@ readBlobs (FilesFromHandle handle) = send (Read (FromHandle handle) pure) readBlobs (FilesFromPaths paths) = traverse (send . flip Read pure . FromPath) paths -- | A task which reads a list of pairs of 'Blob's from a 'Handle' or a list of pairs of 'FilePath's optionally paired with 'Language's. -readBlobPairs :: Has Files sig m => Either (Handle 'IO.ReadMode) [(File, File)] -> m [BlobPair] +readBlobPairs :: Has Files sig m => Either (Handle 'IO.ReadMode) [(File Language, File Language)] -> m [BlobPair] readBlobPairs (Left handle) = send (Read (FromPairHandle handle) pure) readBlobPairs (Right paths) = traverse (send . flip Read pure . uncurry FromPathPair) paths