From cc0f73b1edd2decd28f0958e0bf482a06b8eebd4 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 2 Apr 2018 10:14:46 -0400 Subject: [PATCH] :fire: MonadNonDet. --- src/Analysis/Abstract/BadVariables.hs | 2 +- src/Analysis/Abstract/Caching.hs | 10 +++++----- src/Analysis/Abstract/Collecting.hs | 2 +- src/Analysis/Abstract/Dead.hs | 2 +- src/Analysis/Abstract/Evaluating.hs | 1 - src/Analysis/Abstract/ImportGraph.hs | 2 +- src/Analysis/Abstract/Quiet.hs | 2 +- src/Analysis/Abstract/Tracing.hs | 2 +- 8 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Analysis/Abstract/BadVariables.hs b/src/Analysis/Abstract/BadVariables.hs index ba2a81177..75e7c57b7 100644 --- a/src/Analysis/Abstract/BadVariables.hs +++ b/src/Analysis/Abstract/BadVariables.hs @@ -9,7 +9,7 @@ import Prologue -- An analysis that resumes from evaluation errors and records the list of unresolved free variables. newtype BadVariables m (effects :: [* -> *]) a = BadVariables (m effects a) - deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh, MonadNonDet) + deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh) deriving instance MonadControl term (m effects) => MonadControl term (BadVariables m effects) deriving instance MonadEnvironment location value (m effects) => MonadEnvironment location value (BadVariables m effects) diff --git a/src/Analysis/Abstract/Caching.hs b/src/Analysis/Abstract/Caching.hs index 8071b708e..f87ef40f7 100644 --- a/src/Analysis/Abstract/Caching.hs +++ b/src/Analysis/Abstract/Caching.hs @@ -13,14 +13,14 @@ import Prologue -- | The effects necessary for caching analyses. type CachingEffects location term value effects - = NonDet -- For 'Alternative' and 'MonadNonDet'. + = NonDet -- For 'Alternative' and 'gather'. ': Reader (Cache location term value) -- The in-cache used as an oracle while converging on a result. ': State (Cache location term value) -- The out-cache used to record results in each iteration of convergence. ': effects -- | A (coinductively-)cached analysis suitable for guaranteeing termination of (suitably finitized) analyses over recursive programs. newtype Caching m (effects :: [* -> *]) a = Caching (m effects a) - deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh, MonadNonDet) + deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh) deriving instance MonadControl term (m effects) => MonadControl term (Caching m effects) deriving instance MonadEnvironment location value (m effects) => MonadEnvironment location value (Caching m effects) @@ -65,12 +65,12 @@ instance ( Effectful m isolateCache action = raise (put (mempty :: Cache location term value)) *> action *> raise get -- | This instance coinductively iterates the analysis of a term until the results converge. -instance ( Corecursive term +instance ( Alternative (m effects) + , Corecursive term , Effectful m , Members (CachingEffects location term value '[]) effects , MonadAnalysis location term value (m effects) , MonadFresh (m effects) - , MonadNonDet (m effects) , Ord (Cell location value) , Ord location , Ord term @@ -102,7 +102,7 @@ instance ( Corecursive term -- that it doesn't "leak" to the calling context and diverge (otherwise this -- would never complete). We don’t need to use the values, so we 'gather' the -- nondeterministic values into @()@. - withOracle prevCache (gather (const ()) (liftAnalyze analyzeModule recur m))) mempty + withOracle prevCache (raise (gather (const ()) (lower (liftAnalyze analyzeModule recur m))))) mempty maybe empty scatter (cacheLookup c cache) -- | Iterate a monadic action starting from some initial seed until the results converge. diff --git a/src/Analysis/Abstract/Collecting.hs b/src/Analysis/Abstract/Collecting.hs index 5ee0b7916..92a3a155f 100644 --- a/src/Analysis/Abstract/Collecting.hs +++ b/src/Analysis/Abstract/Collecting.hs @@ -11,7 +11,7 @@ import Data.Abstract.Live import Prologue newtype Collecting m (effects :: [* -> *]) a = Collecting (m effects a) - deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh, MonadNonDet) + deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh) deriving instance MonadControl term (m effects) => MonadControl term (Collecting m effects) deriving instance MonadEnvironment location value (m effects) => MonadEnvironment location value (Collecting m effects) diff --git a/src/Analysis/Abstract/Dead.hs b/src/Analysis/Abstract/Dead.hs index f652acb63..4ff837fd0 100644 --- a/src/Analysis/Abstract/Dead.hs +++ b/src/Analysis/Abstract/Dead.hs @@ -11,7 +11,7 @@ import Prologue -- | An analysis tracking dead (unreachable) code. newtype DeadCode m (effects :: [* -> *]) a = DeadCode (m effects a) - deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh, MonadNonDet) + deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh) deriving instance MonadControl term (m effects) => MonadControl term (DeadCode m effects) deriving instance MonadEnvironment location value (m effects) => MonadEnvironment location value (DeadCode m effects) diff --git a/src/Analysis/Abstract/Evaluating.hs b/src/Analysis/Abstract/Evaluating.hs index f717bf345..2dad060b8 100644 --- a/src/Analysis/Abstract/Evaluating.hs +++ b/src/Analysis/Abstract/Evaluating.hs @@ -27,7 +27,6 @@ newtype Evaluating location term value effects a = Evaluating (Eff effects a) deriving instance Member Fail effects => MonadFail (Evaluating location term value effects) deriving instance Member Fresh effects => MonadFresh (Evaluating location term value effects) deriving instance Member NonDet effects => Alternative (Evaluating location term value effects) -deriving instance Member NonDet effects => MonadNonDet (Evaluating location term value effects) -- | Effects necessary for evaluating (whether concrete or abstract). type EvaluatingEffects location term value diff --git a/src/Analysis/Abstract/ImportGraph.hs b/src/Analysis/Abstract/ImportGraph.hs index 651095f14..0bc0d1ad6 100644 --- a/src/Analysis/Abstract/ImportGraph.hs +++ b/src/Analysis/Abstract/ImportGraph.hs @@ -25,7 +25,7 @@ renderImportGraph :: ImportGraph -> ByteString renderImportGraph = export (defaultStyle friendlyName) . unImportGraph newtype ImportGraphing m (effects :: [* -> *]) a = ImportGraphing (m effects a) - deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh, MonadNonDet) + deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh) deriving instance MonadControl term (m effects) => MonadControl term (ImportGraphing m effects) deriving instance MonadEnvironment location value (m effects) => MonadEnvironment location value (ImportGraphing m effects) diff --git a/src/Analysis/Abstract/Quiet.hs b/src/Analysis/Abstract/Quiet.hs index 4b30215a6..dc04ea439 100644 --- a/src/Analysis/Abstract/Quiet.hs +++ b/src/Analysis/Abstract/Quiet.hs @@ -15,7 +15,7 @@ import Prologue -- -- Note that exceptions thrown by other analyses may not be caught if 'Quietly' doesn’t know about them, i.e. if they’re not part of the generic 'MonadValue', 'MonadAddressable', etc. machinery. newtype Quietly m (effects :: [* -> *]) a = Quietly (m effects a) - deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh, MonadNonDet) + deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh) deriving instance MonadControl term (m effects) => MonadControl term (Quietly m effects) deriving instance MonadEnvironment location value (m effects) => MonadEnvironment location value (Quietly m effects) diff --git a/src/Analysis/Abstract/Tracing.hs b/src/Analysis/Abstract/Tracing.hs index 7dcd0b23a..c5258b903 100644 --- a/src/Analysis/Abstract/Tracing.hs +++ b/src/Analysis/Abstract/Tracing.hs @@ -14,7 +14,7 @@ import Prologue -- -- Instantiating @trace@ to @[]@ yields a linear trace analysis, while @Set@ yields a reachable state analysis. newtype Tracing (trace :: * -> *) m (effects :: [* -> *]) a = Tracing (m effects a) - deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh, MonadNonDet) + deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh) deriving instance MonadControl term (m effects) => MonadControl term (Tracing trace m effects) deriving instance MonadEnvironment location value (m effects) => MonadEnvironment location value (Tracing trace m effects)