mirror of
https://github.com/github/semantic.git
synced 2024-12-23 23:11:50 +03:00
Move traceE to Control.Effect & generalize to Effectful contexts.
This commit is contained in:
parent
97915e1410
commit
67250696ca
@ -2,8 +2,6 @@
|
||||
module Control.Abstract.Evaluator
|
||||
( Evaluator(..)
|
||||
-- * Effects
|
||||
, Trace(..)
|
||||
, traceE
|
||||
, EvalClosure(..)
|
||||
, evaluateClosureBody
|
||||
, runEvalClosure
|
||||
@ -37,9 +35,8 @@ import Control.Monad.Effect.NonDet
|
||||
import Control.Monad.Effect.Reader hiding (runReader)
|
||||
import Control.Monad.Effect.Resumable
|
||||
import Control.Monad.Effect.State hiding (runState)
|
||||
import Control.Monad.Effect.Trace
|
||||
import Data.Abstract.Module
|
||||
import Prologue hiding (trace)
|
||||
import Prologue
|
||||
|
||||
-- | An 'Evaluator' is a thin wrapper around 'Eff' with (phantom) type parameters for the location, term, and value types.
|
||||
--
|
||||
@ -54,12 +51,6 @@ deriving instance Member NonDet effects => Alternative (Evaluator location term
|
||||
|
||||
-- Effects
|
||||
|
||||
-- | Trace into the current context.
|
||||
-- TODO: Someday we can generalize this to work for Task and Graph.
|
||||
traceE :: Member Trace effects => String -> Evaluator location term value effects ()
|
||||
traceE = raise . trace
|
||||
|
||||
|
||||
-- | An effect to evaluate a closure’s body.
|
||||
data EvalClosure term value resume where
|
||||
EvalClosure :: term -> EvalClosure term value value
|
||||
|
@ -5,8 +5,10 @@ module Control.Effect
|
||||
, Eff.Reader
|
||||
, Eff.State
|
||||
, Fresh
|
||||
, Trace
|
||||
, send
|
||||
, throwResumable
|
||||
, traceE
|
||||
-- * Handlers
|
||||
, run
|
||||
, runM
|
||||
@ -28,7 +30,7 @@ import qualified Control.Monad.Effect.Reader as Eff
|
||||
import Control.Monad.Effect.Resumable
|
||||
import qualified Control.Monad.Effect.State as Eff
|
||||
import Control.Monad.Effect.Trace
|
||||
import Prologue hiding (throwError)
|
||||
import Prologue hiding (throwError, trace)
|
||||
|
||||
-- | Types wrapping 'Eff.Eff' actions.
|
||||
--
|
||||
@ -52,6 +54,10 @@ send = raise . Eff.send
|
||||
throwResumable :: (Member (Resumable exc) effects, Effectful m) => exc v -> m effects v
|
||||
throwResumable = raise . throwError
|
||||
|
||||
-- | Trace into the current context.
|
||||
traceE :: (Effectful m, Member Trace effects) => String -> m effects ()
|
||||
traceE = raise . trace
|
||||
|
||||
|
||||
-- Handlers
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user