1
1
mirror of https://github.com/github/semantic.git synced 2024-12-21 13:51:44 +03:00

Merge remote-tracking branch 'origin/master' into floats-scientific

This commit is contained in:
Patrick Thomson 2018-03-07 18:51:50 -05:00
commit 3051ffd147
4 changed files with 16 additions and 7 deletions

View File

@ -80,7 +80,7 @@ instance ( Corecursive t
, Semigroup (Cell (LocationFor v) v)
)
=> MonadAnalysis t v (CachingAnalysis t v) where
evaluateTerm = foldSubterms $ \e -> do
analyzeTerm e = do
c <- getConfiguration (embedSubterm e)
-- Convergence here is predicated upon an Eq instance, not α-equivalence
cache <- converge (\ prevCache -> do

View File

@ -79,6 +79,6 @@ instance ( Corecursive t
, Semigroup (Cell (LocationFor v) v)
)
=> MonadAnalysis t v (DeadCodeAnalysis t v) where
evaluateTerm = foldSubterms (\ term -> do
analyzeTerm term = do
revive (embedSubterm term)
eval term)
eval term

View File

@ -76,4 +76,4 @@ instance ( Evaluatable (Base t)
, Semigroup (Cell (LocationFor v) v)
)
=> MonadAnalysis t v (Evaluation t v) where
evaluateTerm = foldSubterms eval
analyzeTerm = eval

View File

@ -1,9 +1,18 @@
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE DefaultSignatures, FunctionalDependencies #-}
module Control.Abstract.Analysis where
import Prologue
-- | A 'Monad' in which one can evaluate some specific term type to some specific value type.
--
-- This typeclass is left intentionally unconstrained to avoid circular dependencies between it and other typeclasses.
class Monad m => MonadAnalysis term value m | m -> term, m -> value where
-- | Evaluate a term to a value using the semantics of the current analysis. This should always be used instead of explicitly folding 'eval' over subterms, except in 'MonadAnalysis' instances themselves.
evaluateTerm :: term -> m value
-- | Analyze a term using the semantics of the current analysis. This should generally only be called by definitions of 'evaluateTerm' and 'analyzeTerm' in this or other instances.
analyzeTerm :: SubtermAlgebra (Base term) term (m value)
-- | Evaluate a term to a value using the semantics of the current analysis.
--
-- This should always be called instead of explicitly folding either 'eval' or 'analyzeTerm' over subterms, except in 'MonadAnalysis' instances themselves.
evaluateTerm :: MonadAnalysis term value m => term -> m value
default evaluateTerm :: (MonadAnalysis term value m, Recursive term) => term -> m value
evaluateTerm = foldSubterms analyzeTerm