diff --git a/src/Control/Abstract/Evaluator.hs b/src/Control/Abstract/Evaluator.hs index 298bda8f1..eaa070aa7 100644 --- a/src/Control/Abstract/Evaluator.hs +++ b/src/Control/Abstract/Evaluator.hs @@ -24,11 +24,11 @@ module Control.Abstract.Evaluator , module Control.Monad.Effect.Reader , module Control.Monad.Effect.Resumable , module Control.Monad.Effect.State - , Eff.relay + , relay ) where import Control.Effect -import qualified Control.Monad.Effect as Eff +import Control.Monad.Effect import Control.Monad.Effect.Fail import Control.Monad.Effect.Fresh import Control.Monad.Effect.NonDet @@ -39,7 +39,7 @@ import Data.Abstract.Module import Prelude hiding (fail) import Prologue -newtype Evaluator location term value effects a = Evaluator { runEvaluator :: Eff.Eff effects a } +newtype Evaluator location term value effects a = Evaluator { runEvaluator :: Eff effects a } deriving (Applicative, Effectful, Functor, Monad) deriving instance Member NonDet effects => Alternative (Evaluator location term value effects) @@ -52,7 +52,7 @@ data EvalClosure term value resume where EvalClosure :: term -> EvalClosure term value value evaluateClosureBody :: Member (EvalClosure term value) effects => term -> Evaluator location term value effects value -evaluateClosureBody = raise . Eff.send . EvalClosure +evaluateClosureBody = raise . send . EvalClosure runEvalClosure :: (term -> Evaluator location term value effects value) -> Evaluator location term value (EvalClosure term value ': effects) a -> Evaluator location term value effects a runEvalClosure evalClosure = runEffect (\ (EvalClosure term) yield -> evalClosure term >>= yield) @@ -63,7 +63,7 @@ data EvalModule term value resume where EvalModule :: Module term -> EvalModule term value value evaluateModule :: Member (EvalModule term value) effects => Module term -> Evaluator location term value effects value -evaluateModule = raise . Eff.send . EvalModule +evaluateModule = raise . send . EvalModule runEvalModule :: (Module term -> Evaluator location term value effects value) -> Evaluator location term value (EvalModule term value ': effects) a -> Evaluator location term value effects a runEvalModule evalModule = runEffect (\ (EvalModule m) yield -> evalModule m >>= yield) @@ -77,10 +77,10 @@ deriving instance Eq value => Eq (Return value a) deriving instance Show value => Show (Return value a) earlyReturn :: Member (Return value) effects => value -> Evaluator location term value effects value -earlyReturn = raise . Eff.send . Return +earlyReturn = raise . send . Return catchReturn :: Member (Return value) effects => (forall x . Return value x -> Evaluator location term value effects a) -> Evaluator location term value effects a -> Evaluator location term value effects a -catchReturn handler = raiseHandler (Eff.interpose pure (\ ret _ -> lower (handler ret))) +catchReturn handler = raiseHandler (interpose pure (\ ret _ -> lower (handler ret))) runReturn :: Evaluator location term value (Return value ': effects) value -> Evaluator location term value effects value runReturn = runEffect (\ (Return value) _ -> pure value) @@ -95,13 +95,13 @@ deriving instance Eq value => Eq (LoopControl value a) deriving instance Show value => Show (LoopControl value a) throwBreak :: Member (LoopControl value) effects => value -> Evaluator location term value effects value -throwBreak = raise . Eff.send . Break +throwBreak = raise . send . Break throwContinue :: Member (LoopControl value) effects => value -> Evaluator location term value effects value -throwContinue = raise . Eff.send . Continue +throwContinue = raise . send . Continue catchLoopControl :: Member (LoopControl value) effects => Evaluator location term value effects a -> (forall x . LoopControl value x -> Evaluator location term value effects a) -> Evaluator location term value effects a -catchLoopControl action handler = raiseHandler (Eff.interpose pure (\ control _ -> lower (handler control))) action +catchLoopControl action handler = raiseHandler (interpose pure (\ control _ -> lower (handler control))) action runLoopControl :: Evaluator location term value (LoopControl value ': effects) value -> Evaluator location term value effects value runLoopControl = runEffect (\ eff _ -> case eff of