mirror of
https://github.com/github/semantic.git
synced 2024-12-29 18:06:14 +03:00
Interpreters determine their effects.
This commit is contained in:
parent
d0b31667ab
commit
5b18b47db7
@ -1,4 +1,5 @@
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving, ScopedTypeVariables, TypeFamilies, TypeOperators, UndecidableInstances #-}
|
||||
{-# OPTIONS_GHC -Wno-redundant-constraints #-} -- For the Interpreter instance’s MonadEvaluator constraint
|
||||
module Analysis.Abstract.BadAddresses where
|
||||
|
||||
import Control.Abstract.Analysis
|
||||
@ -30,6 +31,7 @@ instance ( Effectful m
|
||||
analyzeModule = liftAnalyze analyzeModule
|
||||
|
||||
instance ( Interpreter effects result rest m
|
||||
, MonadEvaluator location term value effects m
|
||||
, MonadHole value effects m
|
||||
, Monoid (Cell location value)
|
||||
)
|
||||
|
@ -1,4 +1,5 @@
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving, ScopedTypeVariables, TypeFamilies, TypeOperators, UndecidableInstances #-}
|
||||
{-# OPTIONS_GHC -Wno-redundant-constraints #-} -- For the Interpreter instance’s MonadEvaluator constraint
|
||||
module Analysis.Abstract.BadModuleResolutions where
|
||||
|
||||
import Control.Abstract.Analysis
|
||||
@ -27,7 +28,9 @@ instance ( Effectful m
|
||||
|
||||
analyzeModule = liftAnalyze analyzeModule
|
||||
|
||||
instance Interpreter effects result rest m
|
||||
instance ( Interpreter effects result rest m
|
||||
, MonadEvaluator location term value effects m
|
||||
)
|
||||
=> Interpreter (Resumable (ResolutionError value) ': effects) result rest (BadModuleResolutions m) where
|
||||
interpret = interpret . raise @m . relay pure (\ (Resumable err) yield -> case err of
|
||||
RubyError nameToResolve -> yield nameToResolve
|
||||
|
@ -1,4 +1,5 @@
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving, ScopedTypeVariables, TypeFamilies, TypeOperators, UndecidableInstances #-}
|
||||
{-# OPTIONS_GHC -Wno-redundant-constraints #-} -- For the Interpreter instance’s MonadEvaluator constraint
|
||||
module Analysis.Abstract.BadVariables
|
||||
( BadVariables
|
||||
) where
|
||||
@ -37,6 +38,7 @@ instance ( Effectful m
|
||||
analyzeModule = liftAnalyze analyzeModule
|
||||
|
||||
instance ( Interpreter effects (result, [Name]) rest m
|
||||
, MonadEvaluator location term value effects m
|
||||
, MonadHole value (State [Name] ': effects) m
|
||||
)
|
||||
=> Interpreter (Resumable (EvalError value) ': State [Name] ': effects) result rest (BadVariables m) where
|
||||
|
@ -1,4 +1,5 @@
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving, ScopedTypeVariables, TypeFamilies, TypeOperators, UndecidableInstances #-}
|
||||
{-# OPTIONS_GHC -Wno-redundant-constraints #-} -- For the Interpreter instance’s MonadEvaluator constraint
|
||||
module Analysis.Abstract.Caching
|
||||
( Caching
|
||||
) where
|
||||
@ -122,6 +123,7 @@ scatter = foldMapA (\ (value, heap') -> putHeap heap' $> value)
|
||||
|
||||
|
||||
instance ( Interpreter effects ([result], Cache location term value) rest m
|
||||
, MonadEvaluator location term value effects m
|
||||
, Ord (Cell location value)
|
||||
, Ord location
|
||||
, Ord term
|
||||
|
@ -1,4 +1,5 @@
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving, ScopedTypeVariables, TypeFamilies, TypeOperators, UndecidableInstances #-}
|
||||
{-# OPTIONS_GHC -Wno-redundant-constraints #-} -- For the Interpreter instance’s MonadEvaluator constraint
|
||||
module Analysis.Abstract.Collecting
|
||||
( Collecting
|
||||
) where
|
||||
@ -79,6 +80,7 @@ reachable roots heap = go mempty roots
|
||||
|
||||
|
||||
instance ( Interpreter effects result rest m
|
||||
, MonadEvaluator location term value effects m
|
||||
, Ord location
|
||||
)
|
||||
=> Interpreter (Reader (Live location value) ': effects) result rest (Collecting m) where
|
||||
|
@ -1,4 +1,5 @@
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving, ScopedTypeVariables, TypeFamilies, TypeOperators, UndecidableInstances #-}
|
||||
{-# OPTIONS_GHC -Wno-redundant-constraints #-} -- For the Interpreter instance’s MonadEvaluator constraint
|
||||
module Analysis.Abstract.Dead
|
||||
( DeadCode
|
||||
) where
|
||||
@ -54,6 +55,7 @@ instance ( Corecursive term
|
||||
liftAnalyze analyzeModule recur m
|
||||
|
||||
instance ( Interpreter effects (result, Dead term) rest m
|
||||
, MonadEvaluator location term value effects m
|
||||
, Ord term
|
||||
)
|
||||
=> Interpreter (State (Dead term) ': effects) result rest (DeadCode m) where
|
||||
|
@ -1,4 +1,5 @@
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving, ScopedTypeVariables, TypeFamilies, TypeOperators, UndecidableInstances #-}
|
||||
{-# OPTIONS_GHC -Wno-redundant-constraints #-} -- For the Interpreter instance’s MonadEvaluator constraint
|
||||
module Analysis.Abstract.Quiet
|
||||
( Quietly
|
||||
) where
|
||||
@ -33,6 +34,7 @@ instance ( Effectful m
|
||||
analyzeModule = liftAnalyze analyzeModule
|
||||
|
||||
instance ( Interpreter effects result rest m
|
||||
, MonadEvaluator location term value effects m
|
||||
, MonadHole value effects m
|
||||
)
|
||||
=> Interpreter (Resumable (Unspecialized value) ': effects) result rest (Quietly m) where
|
||||
|
@ -1,4 +1,5 @@
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving, ScopedTypeVariables, TypeFamilies, TypeOperators, UndecidableInstances #-}
|
||||
{-# OPTIONS_GHC -Wno-redundant-constraints #-} -- For the Interpreter instance’s MonadEvaluator constraint
|
||||
module Analysis.Abstract.Tracing
|
||||
( Tracing
|
||||
) where
|
||||
@ -36,6 +37,7 @@ instance ( Corecursive term
|
||||
analyzeModule = liftAnalyze analyzeModule
|
||||
|
||||
instance ( Interpreter effects (result, trace (Configuration location term value)) rest m
|
||||
, MonadEvaluator location term value effects m
|
||||
, Monoid (trace (Configuration location term value))
|
||||
)
|
||||
=> Interpreter (Writer (trace (Configuration location term value)) ': effects) result rest (Tracing trace m) where
|
||||
|
@ -47,7 +47,7 @@ class MonadEvaluator location term value effects m => MonadAnalysis location ter
|
||||
isolate :: m effects a -> m effects a
|
||||
isolate = withEnv mempty . withExports mempty
|
||||
|
||||
class Effectful m => Interpreter effects result function m | m effects result -> function where
|
||||
class Effectful m => Interpreter effects result function m | m -> effects, m result -> function where
|
||||
interpret :: m effects result -> function
|
||||
|
||||
instance Interpreter '[] result result Eff where
|
||||
|
Loading…
Reference in New Issue
Block a user