From 4c5734452ad18563def9ec5a4854db7ebee2d0f7 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Sun, 6 May 2018 13:29:05 -0400 Subject: [PATCH] :fire: the termInfo parameter from Located. --- src/Analysis/Abstract/ImportGraph.hs | 14 +++++++------- src/Data/Abstract/Located.hs | 8 ++++---- src/Semantic/Graph.hs | 24 ++++++++++++------------ 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Analysis/Abstract/ImportGraph.hs b/src/Analysis/Abstract/ImportGraph.hs index 50333ab8e..9d9359f06 100644 --- a/src/Analysis/Abstract/ImportGraph.hs +++ b/src/Analysis/Abstract/ImportGraph.hs @@ -56,17 +56,17 @@ style = (defaultStyle vertexName) graphingTerms :: forall location term value effects syntax ann a . ( Element Syntax.Identifier syntax - , Members '[ Reader (Environment (Located location (Base term ())) value) + , Members '[ Reader (Environment (Located location) value) , Reader ModuleInfo , Reader PackageInfo , Resumable (LoadError term) - , State (Environment (Located location (Base term ())) value) + , State (Environment (Located location) value) , State (ImportGraph term) ] effects , term ~ Term (Sum syntax) ann ) - => SubtermAlgebra (Base term) term (Evaluator (Located location (Base term ())) term value effects a) - -> SubtermAlgebra (Base term) term (Evaluator (Located location (Base term ())) term value effects a) + => SubtermAlgebra (Base term) term (Evaluator (Located location) term value effects a) + -> SubtermAlgebra (Base term) term (Evaluator (Located location) term value effects a) graphingTerms recur term@(In _ syntax) = do case projectSum syntax of Just (Syntax.Identifier name) -> do @@ -118,12 +118,12 @@ moduleInclusion v = do appendGraph (moduleGraph m `connect` vertex v) -- | Add an edge from the passed variable name to the module it originated within. -variableDefinition :: ( Member (Reader (Environment (Located location (Base term ())) value)) effects - , Member (State (Environment (Located location (Base term ())) value)) effects +variableDefinition :: ( Member (Reader (Environment (Located location) value)) effects + , Member (State (Environment (Located location) value)) effects , Member (State (ImportGraph term)) effects ) => Name - -> Evaluator (Located location (Base term ())) term value effects () + -> Evaluator (Located location) term value effects () variableDefinition name = do graph <- maybe empty (moduleGraph . locationModule . unAddress) <$> lookupEnv name appendGraph (vertex (Variable (unName name)) `connect` graph) diff --git a/src/Data/Abstract/Located.hs b/src/Data/Abstract/Located.hs index 692521f56..6a5419148 100644 --- a/src/Data/Abstract/Located.hs +++ b/src/Data/Abstract/Located.hs @@ -8,18 +8,18 @@ import Data.Abstract.Module (ModuleInfo) import Data.Abstract.Package (PackageInfo) import Prologue -data Located location termInfo = Located { location :: location, locationPackage :: {-# UNPACK #-} !PackageInfo, locationModule :: {-# UNPACK #-} !ModuleInfo } +data Located location = Located { location :: location, locationPackage :: {-# UNPACK #-} !PackageInfo, locationModule :: {-# UNPACK #-} !ModuleInfo } deriving (Eq, Ord, Show) -instance Location location => Location (Located location termInfo) where - type Cell (Located location termInfo) = Cell location +instance Location location => Location (Located location) where + type Cell (Located location) = Cell location instance ( Addressable location effects , Members '[ Reader ModuleInfo , Reader PackageInfo ] effects ) - => Addressable (Located location termInfo) effects where + => Addressable (Located location) effects where derefCell (Address (Located loc _ _)) = raise . lower . derefCell (Address loc) allocLoc name = raise (lower (Located <$> allocLoc name <*> currentPackage <*> currentModule)) diff --git a/src/Semantic/Graph.hs b/src/Semantic/Graph.hs index 539b3d283..5832505d6 100644 --- a/src/Semantic/Graph.hs +++ b/src/Semantic/Graph.hs @@ -62,22 +62,22 @@ parseModule parser rootDir file = do importGraphAnalysis :: forall term syntax ann a - . Evaluator (Located Precise (Base term ())) term (Value (Located Precise (Base term ()))) + . Evaluator (Located Precise) term (Value (Located Precise)) ( State (ImportGraph (Term (Sum syntax) ann)) - ': Resumable (AddressError (Located Precise (Base term ())) (Value (Located Precise (Base term ())))) + ': Resumable (AddressError (Located Precise) (Value (Located Precise))) ': Resumable ResolutionError - ': Resumable (EvalError (Value (Located Precise (Base term ())))) + ': Resumable (EvalError (Value (Located Precise))) ': State [Name] - ': Resumable (ValueError (Located Precise (Base term ())) (Value (Located Precise (Base term ())))) - ': Resumable (Unspecialized (Value (Located Precise (Base term ())))) + ': Resumable (ValueError (Located Precise) (Value (Located Precise))) + ': Resumable (Unspecialized (Value (Located Precise))) ': Resumable (LoadError term) - ': EvaluatingEffects (Located Precise (Base term ())) term (Value (Located Precise (Base term ())))) a - -> ( Either String -- 'fail' calls - ( Either (SomeExc (LoadError term)) -- Unhandled LoadErrors - ( ( a -- the result value - , ImportGraph (Term (Sum syntax) ann)) -- the import graph - , [Name])) -- the list of bad names - , EvaluatingState (Located Precise (Base term ())) term (Value (Located Precise (Base term ())))) -- the final state + ': EvaluatingEffects (Located Precise) term (Value (Located Precise))) a + -> ( Either String -- 'fail' calls + ( Either (SomeExc (LoadError term)) -- Unhandled LoadErrors + ( ( a -- the result value + , ImportGraph (Term (Sum syntax) ann)) -- the import graph + , [Name])) -- the list of bad names + , EvaluatingState (Located Precise) term (Value (Located Precise))) -- the final state importGraphAnalysis = evaluating . erroring @(LoadError term)