From 199372d0f37e1be3e484fb2937eb4d70cf0e3639 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 30 Sep 2019 16:00:21 -0400 Subject: [PATCH] Serializing requires only the config. --- src/Semantic/AST.hs | 3 ++- src/Semantic/Api/Diffs.hs | 3 ++- src/Semantic/Api/Terms.hs | 3 ++- src/Semantic/Task.hs | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Semantic/AST.hs b/src/Semantic/AST.hs index 838cf2e1b..98d16305a 100644 --- a/src/Semantic/AST.hs +++ b/src/Semantic/AST.hs @@ -18,6 +18,7 @@ import Data.AST import Data.Blob import Parsing.Parser import Rendering.JSON (renderJSONAST) +import Semantic.Config import Semantic.Task import qualified Serializing.Format as F @@ -36,7 +37,7 @@ astParseBlob blob@Blob{..} data ASTFormat = SExpression | JSON | Show | Quiet deriving (Show) -runASTParse :: (Member Distribute sig, Member (Error SomeException) sig, Member Parse sig, Member (Reader TaskSession) sig, Carrier sig m, MonadIO m) => ASTFormat -> [Blob] -> m F.Builder +runASTParse :: (Member Distribute sig, Member (Error SomeException) sig, Member Parse sig, Member (Reader Config) sig, Carrier sig m, MonadIO m) => ASTFormat -> [Blob] -> m F.Builder runASTParse SExpression = distributeFoldMap (astParseBlob >=> withSomeAST (serialize (F.SExpression F.ByShow))) runASTParse Show = distributeFoldMap (astParseBlob >=> withSomeAST (serialize F.Show . fmap nodeSymbol)) runASTParse JSON = distributeFoldMap (\ blob -> withSomeAST (renderJSONAST blob) <$> astParseBlob blob) >=> serialize F.JSON diff --git a/src/Semantic/Api/Diffs.hs b/src/Semantic/Api/Diffs.hs index 78b2886d6..0a4b81d66 100644 --- a/src/Semantic/Api/Diffs.hs +++ b/src/Semantic/Api/Diffs.hs @@ -35,6 +35,7 @@ import Rendering.Graph import Rendering.JSON hiding (JSON) import qualified Rendering.JSON import Semantic.Api.Bridge +import Semantic.Config import Semantic.Proto.SemanticPB hiding (Blob, BlobPair) import Semantic.Task as Task import Semantic.Telemetry as Stat @@ -96,7 +97,7 @@ dotGraphDiff :: (DiffEffects sig m) => BlobPair -> m Builder dotGraphDiff blobPair = doDiff blobPair (const id) render where render _ = serialize (DOT (diffStyle "diffs")) . renderTreeGraph -type DiffEffects sig m = (Member (Error SomeException) sig, Member (Reader TaskSession) sig, Member Telemetry sig, Member Distribute sig, Member Parse sig, Carrier sig m, MonadIO m) +type DiffEffects sig m = (Member (Error SomeException) sig, Member (Reader Config) sig, Member (Reader TaskSession) sig, Member Telemetry sig, Member Distribute sig, Member Parse sig, Carrier sig m, MonadIO m) type CanDiff syntax = (ConstructorName syntax, Diffable syntax, Eq1 syntax, HasDeclaration syntax, Hashable1 syntax, Show1 syntax, ToJSONFields1 syntax, Traversable syntax) type Decorate a b = forall syntax . CanDiff syntax => Blob -> Term syntax a -> Term syntax b diff --git a/src/Semantic/Api/Terms.hs b/src/Semantic/Api/Terms.hs index f6dce4281..ef2327edb 100644 --- a/src/Semantic/Api/Terms.hs +++ b/src/Semantic/Api/Terms.hs @@ -37,6 +37,7 @@ import Rendering.Graph import Rendering.JSON hiding (JSON) import qualified Rendering.JSON import Semantic.Api.Bridge +import Semantic.Config import Semantic.Proto.SemanticPB hiding (Blob) import Semantic.Task import Serializing.Format hiding (JSON) @@ -102,7 +103,7 @@ quietTerm blob = showTiming blob <$> time' ( (doParse blob >>= withSomeTerm (fma in stringUtf8 (status <> "\t" <> show (blobLanguage blob) <> "\t" <> blobPath blob <> "\t" <> show duration <> " ms\n") -type ParseEffects sig m = (Member (Error SomeException) sig, Member (Reader PerLanguageModes) sig, Member Parse sig, Member (Reader TaskSession) sig, Carrier sig m) +type ParseEffects sig m = (Member (Error SomeException) sig, Member (Reader PerLanguageModes) sig, Member Parse sig, Member (Reader Config) sig, Member (Reader TaskSession) sig, Carrier sig m) type TermConstraints = '[ Taggable diff --git a/src/Semantic/Task.hs b/src/Semantic/Task.hs index 327999431..17dadba95 100644 --- a/src/Semantic/Task.hs +++ b/src/Semantic/Task.hs @@ -108,12 +108,12 @@ parse :: (Member Parse sig, Carrier sig m) -> m term parse parser blob = send (Parse parser blob pure) -serialize :: (Member (Reader TaskSession) sig, Carrier sig m) +serialize :: (Member (Reader Config) sig, Carrier sig m) => Format input -> input -> m Builder serialize format input = do - formatStyle <- asks (Flag.choose IsTerminal Plain Colourful . configIsTerminal . config) + formatStyle <- asks (Flag.choose IsTerminal Plain Colourful . configIsTerminal) pure (runSerialize formatStyle format input) data TaskSession