From 6ed41a911c674137c3c82bc67c7b18cb3a22a650 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 7 Mar 2018 18:35:56 -0500 Subject: [PATCH] Move the Ord constraint on the location into the class methods requiring it. --- src/Analysis/Abstract/Tracing.hs | 2 ++ src/Control/Abstract/Evaluator.hs | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Analysis/Abstract/Tracing.hs b/src/Analysis/Abstract/Tracing.hs index f7d9c6d86..cd75144af 100644 --- a/src/Analysis/Abstract/Tracing.hs +++ b/src/Analysis/Abstract/Tracing.hs @@ -6,6 +6,7 @@ import Control.Abstract.Evaluator import Control.Monad.Effect.Writer import Data.Abstract.Configuration import Data.Semigroup.Reducer as Reducer +import Data.Abstract.Value import Prologue type Trace trace term value = trace (ConfigurationFor term value) @@ -27,6 +28,7 @@ instance ( Corecursive (TermFor m) , Member (TracerFor trace m) (Effects m) , MonadAnalysis m , MonadEvaluator m + , Ord (LocationFor (ValueFor m)) , Recursive (TermFor m) , Reducer (ConfigurationFor (TermFor m) (ValueFor m)) (TraceFor trace m) ) diff --git a/src/Control/Abstract/Evaluator.hs b/src/Control/Abstract/Evaluator.hs index 64550854d..bf1632e64 100644 --- a/src/Control/Abstract/Evaluator.hs +++ b/src/Control/Abstract/Evaluator.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE DataKinds, DefaultSignatures, GeneralizedNewtypeDeriving, RankNTypes, StandaloneDeriving, TypeFamilies, UndecidableInstances #-} +{-# LANGUAGE ConstrainedClassMethods, DataKinds, DefaultSignatures, GeneralizedNewtypeDeriving, RankNTypes, StandaloneDeriving, TypeFamilies, UndecidableInstances #-} module Control.Abstract.Evaluator where import Control.Abstract.Analysis @@ -18,7 +18,7 @@ import Prelude hiding (fail) -- - environments binding names to addresses -- - a heap mapping addresses to (possibly sets of) values -- - tables of modules available for import -class (MonadFail m, Ord (LocationFor (ValueFor m))) => MonadEvaluator m where +class MonadFail m => MonadEvaluator m where -- | Retrieve the global environment. getGlobalEnv :: m (EnvironmentFor (ValueFor m)) -- | Update the global environment. @@ -45,11 +45,11 @@ class (MonadFail m, Ord (LocationFor (ValueFor m))) => MonadEvaluator m where localModuleTable :: (Linker (TermFor m) -> Linker (TermFor m)) -> m a -> m a -- | Retrieve the current root set. - askRoots :: m (Live (LocationFor (ValueFor m)) (ValueFor m)) + askRoots :: Ord (LocationFor (ValueFor m)) => m (Live (LocationFor (ValueFor m)) (ValueFor m)) askRoots = pure mempty -- | Get the current 'Configuration' with a passed-in term. - getConfiguration :: term -> m (Configuration (LocationFor (ValueFor m)) term (ValueFor m)) + getConfiguration :: Ord (LocationFor (ValueFor m)) => term -> m (Configuration (LocationFor (ValueFor m)) term (ValueFor m)) getConfiguration term = Configuration term <$> askRoots <*> askLocalEnv <*> getStore type EvaluatorEffects term value