From f0b96e793d1832ff8ba23e6b9b669df66b7edc4c Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Tue, 12 Jun 2018 11:54:25 -0400 Subject: [PATCH] remove unused functions --- src/Data/Graph/AdjList.hs | 1 + src/Data/Project.hs | 46 +-------------------------------------- src/Semantic/IO.hs | 3 +-- src/Semantic/Task.hs | 2 -- 4 files changed, 3 insertions(+), 49 deletions(-) diff --git a/src/Data/Graph/AdjList.hs b/src/Data/Graph/AdjList.hs index 4a48a17f3..3dca719c2 100644 --- a/src/Data/Graph/AdjList.hs +++ b/src/Data/Graph/AdjList.hs @@ -88,6 +88,7 @@ graphToAdjList = taggedGraphToAdjList . tagGraph -- Using a PBGraph as the accumulator for the fold would incur -- significant overhead associated with Vector concatenation. -- We use this and then pay the O(v + e) to-Vector cost once. +-- The fields are strict because we have StrictData on. data Acc = Acc [Vertex] (HashSet Edge) -- Convert a graph with tagged members to a protobuf-compatible adjacency list. diff --git a/src/Data/Project.hs b/src/Data/Project.hs index 4a8e9103a..9361f2090 100644 --- a/src/Data/Project.hs +++ b/src/Data/Project.hs @@ -12,9 +12,6 @@ module Data.Project ( , projectEntryPoints , projectFiles , readFile - , readBlobFromPath - , readBlobPair - , addPrelude -- * Files , File (..) , file @@ -25,11 +22,8 @@ import Prologue hiding (throwError) import Control.Monad.Effect import Control.Monad.Effect.Exception -import Control.Monad.IO.Class import Data.Blob -import qualified Data.ByteString as B import Data.Language -import Data.Source import qualified Data.Text as T import Debug.Trace import Proto3.Suite @@ -92,7 +86,6 @@ projectEntryPoints (Project {..})= foldr go [] projectBlobs projectFiles :: Concrete -> [File] projectFiles = fmap toFile . projectBlobs where - data File = File { filePath :: FilePath , fileLanguage :: Language @@ -102,37 +95,14 @@ file :: FilePath -> File file path = File path (languageForFilePath path) where languageForFilePath = languageForType . takeExtension +-- This is kind of a wart; Blob should really hold a 'File'. toFile :: Blob -> File toFile (Blob _ p l) = File p l data ProjectException = FileNotFound FilePath - | EmptyPairProvided - | PairNotFound (Both FilePath) - | HandleNotSupported - | WritesNotSupported - | NoLanguagesSpecified - | UnknownLanguage - | MultipleLanguagesSpecified [Language] - | TODO deriving (Show, Eq, Typeable, Exception) -readBlobFromPath :: Member (Exc SomeException) effs - => Concrete - -> File - -> Eff effs Blob -readBlobFromPath g f = readFile g f >>= maybeM (throwError (SomeException (FileNotFound (filePath f)))) - -addPrelude :: MonadIO m - => Concrete - -> File - -> m Concrete -addPrelude g File{..} = do - traceM "Adding to prelude" - contents <- liftIO (B.readFile filePath) - let blob = Blob (fromUTF8 contents) filePath fileLanguage - pure $ g { projectBlobs = blob : projectBlobs g } - readFile :: Member (Exc SomeException) effs => Concrete -> File @@ -144,17 +114,3 @@ readFile Project{..} f = | p == "/dev/null" -> pure Nothing | isJust candidate -> pure candidate | otherwise -> throwError (SomeException (FileNotFound p)) - -readBlobPair :: Member (Exc SomeException) effs - => Concrete - -> File - -> File - -> Eff effs BlobPair -readBlobPair g f1 f2 = Join <$> join (maybeThese <$> readFile g f1 <*> readFile g f2) - -maybeThese :: Member (Exc SomeException) effs => Maybe a -> Maybe b -> Eff effs (These a b) -maybeThese a b = case (a, b) of - (Just a, Nothing) -> pure (This a) - (Nothing, Just b) -> pure (That b) - (Just a, Just b) -> pure (These a b) - _ -> throwError (SomeException EmptyPairProvided) diff --git a/src/Semantic/IO.hs b/src/Semantic/IO.hs index 85bf1be2e..2b8420f8f 100644 --- a/src/Semantic/IO.hs +++ b/src/Semantic/IO.hs @@ -37,14 +37,13 @@ module Semantic.IO import qualified Control.Exception as Exc import Control.Monad.Effect -import Control.Monad.Effect.State import Control.Monad.Effect.Exception import Control.Monad.IO.Class import Data.Aeson import Data.Blob import Data.Bool import qualified Data.Project as Project -import Data.Project (File (..), ProjectException (..)) +import Data.Project (File (..)) import qualified Data.ByteString as B import qualified Data.ByteString.Builder as B import qualified Data.ByteString.Lazy as BL diff --git a/src/Semantic/Task.hs b/src/Semantic/Task.hs index c10d4993c..a686184b1 100644 --- a/src/Semantic/Task.hs +++ b/src/Semantic/Task.hs @@ -55,7 +55,6 @@ import Control.Monad import Control.Monad.Effect import Control.Monad.Effect.Exception import Control.Monad.Effect.Reader -import Control.Monad.Effect.State import Control.Monad.Effect.Trace import Data.Blob import Data.Bool @@ -66,7 +65,6 @@ import Data.Record import Data.Sum import qualified Data.Syntax as Syntax import Data.Term -import Data.Project import Diffing.Algorithm (Diffable) import Diffing.Interpreter import Parsing.CMark