From 514a55a62bf8fc7935694b7f97ec3036a0acda04 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 31 May 2017 12:35:18 -0400 Subject: [PATCH] Export a parseBlobs helper from Semantic. --- src/Semantic.hs | 6 +++++- src/SemanticCmdLine.hs | 5 ++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Semantic.hs b/src/Semantic.hs index 8de4f39d5..061ccdbdb 100644 --- a/src/Semantic.hs +++ b/src/Semantic.hs @@ -1,6 +1,7 @@ {-# LANGUAGE GADTs #-} module Semantic -( parseBlob +( parseBlobs +, parseBlob , diffBlobPair , diffAndRenderTermPair ) where @@ -28,6 +29,9 @@ import Term -- - Built in concurrency where appropriate. -- - Easy to consume this interface from other application (e.g a cmdline or web server app). +parseBlobs :: (Monoid output, StringConv output ByteString) => TermRenderer output -> [SourceBlob] -> Task ByteString +parseBlobs renderer = fmap toS . distributeFoldMap (parseBlob renderer) . filter (not . nonExistentBlob) + -- | A task to parse a 'SourceBlob' and render the resulting 'Term'. parseBlob :: TermRenderer output -> SourceBlob -> Task output parseBlob renderer blob@SourceBlob{..} = case renderer of diff --git a/src/SemanticCmdLine.hs b/src/SemanticCmdLine.hs index 733e5b8fa..0a6bea202 100644 --- a/src/SemanticCmdLine.hs +++ b/src/SemanticCmdLine.hs @@ -14,14 +14,13 @@ import Prologue hiding (concurrently, fst, snd, readFile) import qualified Data.ByteString as B import qualified Paths_semantic_diff as Library (version) import qualified Semantic.Task as Task -import Source (nonExistentBlob) import System.Directory import System.Environment import System.FilePath.Posix (takeFileName, (-<.>)) import System.IO.Error (IOError) import System.IO (stdin) import Text.Regex -import qualified Semantic (parseBlob, diffBlobPair) +import qualified Semantic (parseBlobs, diffBlobPair) main :: IO () main = do @@ -62,7 +61,7 @@ runParse ParseArguments{..} = do ParsePaths paths -> traverse (uncurry readFile) paths ParseCommit sha paths -> readFilesAtSHA gitDir alternateObjectDirs paths sha ParseStdin -> readBlobsFromHandle stdin - Task.runTask . fmap toS $ Task.distributeFoldMap (Semantic.parseBlob parseTreeRenderer) (filter (not . nonExistentBlob) blobs) + Task.runTask (Semantic.parseBlobs parseTreeRenderer blobs) -- | A parser for the application's command-line arguments. arguments :: FilePath -> [FilePath] -> ParserInfo Arguments