From 40cd003fd3f6d5b06a6ba1c9c7d71d43a4e3816d Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 11 Dec 2018 13:53:09 -0500 Subject: [PATCH] Factor runDomainEffects out of evaluate. --- src/Semantic/Analysis.hs | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/Semantic/Analysis.hs b/src/Semantic/Analysis.hs index 3d99102de..7ecc934f0 100644 --- a/src/Semantic/Analysis.hs +++ b/src/Semantic/Analysis.hs @@ -103,9 +103,41 @@ evaluate lang perModule runTerm modules = do . raiseHandler (runReader (CurrentScope scopeAddress)) . runReturn . runLoopControl - . perModule (runDomainEffects . moduleBody) + . perModule (runDomainEffects runTerm . moduleBody) - runDomainEffects = raiseHandler runInterpose . runBoolean . runWhile . runFunction runTerm . either ((unit <$) . definePrelude) runTerm +runDomainEffects :: ( AbstractValue term address value (ValueC term address value m) + , Carrier sig m + , booleanC ~ BooleanC value (Eff (InterposeC (Resumable (BaseError (UnspecializedError address value))) (Eff m))) + , booleanSig ~ (Boolean value :+: Interpose (Resumable (BaseError (UnspecializedError address value))) :+: sig) + , Carrier booleanSig booleanC + , whileC ~ WhileC value (Eff booleanC) + , whileSig ~ (While value :+: booleanSig) + , Carrier whileSig whileC + , functionC ~ FunctionC term address value (Eff whileC) + , functionSig ~ (Function term address value :+: whileSig) + , Carrier functionSig functionC + , HasPrelude lang + , Member (Allocator address) sig + , Member (Deref value) sig + , Member Fresh sig + , Member (Reader (CurrentFrame address)) sig + , Member (Reader (CurrentScope address)) sig + , Member (Reader ModuleInfo) sig + , Member (Reader Span) sig + , Member (Resumable (BaseError (AddressError address value))) sig + , Member (Resumable (BaseError (HeapError address))) sig + , Member (Resumable (BaseError (ScopeError address))) sig + , Member (Resumable (BaseError (UnspecializedError address value))) sig + , Member (State (Heap address address value)) sig + , Member (State (ScopeGraph address)) sig + , Member Trace sig + , Ord address + , Show address + ) + => (term -> Evaluator term address value (ValueC term address value m) value) + -> Either (proxy lang) term + -> Evaluator term address value m value +runDomainEffects runTerm = raiseHandler runInterpose . runBoolean . runWhile . runFunction runTerm . either ((unit <$) . definePrelude) runTerm -- | Evaluate a term recursively, applying the passed function at every recursive position. --