mirror of
https://github.com/github/semantic.git
synced 2024-12-01 09:15:01 +03:00
Traverse in default eval
This commit is contained in:
parent
e2b117cecd
commit
e57a46063f
@ -42,7 +42,7 @@ import Data.Term
|
||||
import Prologue
|
||||
|
||||
-- | The 'Evaluatable' class defines the necessary interface for a term to be evaluated. While a default definition of 'eval' is given, instances with computational content must implement 'eval' to perform their small-step operational semantics.
|
||||
class Show1 constr => Evaluatable constr where
|
||||
class (Show1 constr, Foldable constr) => Evaluatable constr where
|
||||
eval :: ( AbstractValue address value effects
|
||||
, Declarations term
|
||||
, FreeVariables term
|
||||
@ -61,7 +61,10 @@ class Show1 constr => Evaluatable constr where
|
||||
, Member Trace effects
|
||||
)
|
||||
=> SubtermAlgebra constr term (Evaluator address value effects (ValueRef address))
|
||||
eval expr = rvalBox =<< throwResumable (Unspecialized ("Eval unspecialized for " <> liftShowsPrec (const (const id)) (const id) 0 expr ""))
|
||||
eval expr = do
|
||||
void $ traverse_ subtermValue expr
|
||||
v <- throwResumable (Unspecialized ("Eval unspecialized for " <> liftShowsPrec (const (const id)) (const id) 0 expr ""))
|
||||
rvalBox v
|
||||
|
||||
|
||||
evaluate :: ( AbstractValue address value inner
|
||||
@ -230,7 +233,7 @@ runUnspecializedWith = runResumableWith
|
||||
-- Instances
|
||||
|
||||
-- | If we can evaluate any syntax which can occur in a 'Sum', we can evaluate the 'Sum'.
|
||||
instance (Apply Evaluatable fs, Apply Show1 fs) => Evaluatable (Sum fs) where
|
||||
instance (Apply Evaluatable fs, Apply Show1 fs, Apply Foldable fs) => Evaluatable (Sum fs) where
|
||||
eval = apply @Evaluatable eval
|
||||
|
||||
-- | Evaluating a 'TermF' ignores its annotation, evaluating the underlying syntax.
|
||||
|
@ -41,7 +41,7 @@ import Semantic.Task as Task
|
||||
|
||||
data GraphType = ImportGraph | CallGraph
|
||||
|
||||
type AnalysisClasses = '[ Declarations1, Eq1, Evaluatable, FreeVariables1, Functor, Ord1, Show1 ]
|
||||
type AnalysisClasses = '[ Declarations1, Eq1, Evaluatable, FreeVariables1, Foldable, Functor, Ord1, Show1 ]
|
||||
|
||||
runGraph :: (Member Distribute effs, Member (Exc SomeException) effs, Member Resolution effs, Member Task effs, Member Trace effs)
|
||||
=> GraphType
|
||||
|
Loading…
Reference in New Issue
Block a user