1
1
mirror of https://github.com/github/semantic.git synced 2024-12-19 12:51:52 +03:00

Lift runM into Effectful contexts.

This commit is contained in:
Rob Rix 2018-05-08 10:35:07 -04:00
parent c153815859
commit 1320d6a9c0
2 changed files with 7 additions and 4 deletions

View File

@ -8,6 +8,7 @@ module Control.Effect
, throwResumable
-- * Handlers
, run
, runM
, runEffect
, raiseHandler
, runReader
@ -53,6 +54,9 @@ throwResumable = raise . throwError
run :: Effectful m => m '[] a -> a
run = Eff.run . lower
runM :: (Effectful m, Monad f) => m '[f] a -> f a
runM = Eff.runM . lower
runEffect :: Effectful m => (forall v . effect v -> (v -> m effects a) -> m effects a) -> m (effect ': effects) a -> m effects a
runEffect handler = raiseHandler (Eff.relay pure (\ effect yield -> lower (handler effect (raise . yield))))

View File

@ -7,7 +7,6 @@ import Analysis.Abstract.Collecting
import Analysis.Abstract.Evaluating as X
import Control.Abstract.Evaluator
import Control.Effect (runPrintingTraces)
import Control.Monad.Effect (runM)
import Data.Abstract.Address
import Data.Abstract.Evaluatable
import Data.Abstract.Value
@ -27,7 +26,7 @@ import qualified Language.Python.Assignment as Python
import qualified Language.Ruby.Assignment as Ruby
justEvaluating
= runM . lower
= runM
. fmap (first reassociate)
. evaluating
. runPrintingTraces
@ -41,7 +40,7 @@ justEvaluating
. constrainedToValuePrecise
evaluatingWithHoles
= runM . lower
= runM
. evaluating
. runPrintingTraces
. resumingLoadError
@ -55,7 +54,7 @@ evaluatingWithHoles
-- The order is significant here: caching has to run before typeChecking, or else well nondeterministically produce TypeErrors as part of the result set. While this is probably actually correct, it will require us to have an Ord instance for TypeError, which we dont have yet.
checking
= runM . lower
= runM
. fmap (first reassociate)
. evaluating
. runPrintingTraces