mirror of
https://github.com/github/semantic.git
synced 2024-12-24 23:42:31 +03:00
runEffects produces the final result directly.
This commit is contained in:
parent
8ff194439c
commit
a2dffe278c
@ -13,7 +13,6 @@ module Control.Abstract.Analysis
|
|||||||
|
|
||||||
import Control.Abstract.Evaluator as X
|
import Control.Abstract.Evaluator as X
|
||||||
import Control.Effect as X
|
import Control.Effect as X
|
||||||
import qualified Control.Monad.Effect as Effect
|
|
||||||
import Control.Monad.Effect.Fail as X
|
import Control.Monad.Effect.Fail as X
|
||||||
import Control.Monad.Effect.Fresh as X
|
import Control.Monad.Effect.Fresh as X
|
||||||
import Control.Monad.Effect.NonDet as X
|
import Control.Monad.Effect.NonDet as X
|
||||||
@ -100,4 +99,4 @@ runAnalysis :: ( Effectful m
|
|||||||
)
|
)
|
||||||
=> m effects a
|
=> m effects a
|
||||||
-> Final effects a
|
-> Final effects a
|
||||||
runAnalysis = Effect.run . runEffects . lower
|
runAnalysis = runEffects . lower
|
||||||
|
@ -13,21 +13,21 @@ import Prologue
|
|||||||
|
|
||||||
-- | Run an 'Effectful' computation to completion, interpreting each effect with some sensible defaults, and return the 'Final' result.
|
-- | Run an 'Effectful' computation to completion, interpreting each effect with some sensible defaults, and return the 'Final' result.
|
||||||
run :: (Effectful m, RunEffects effects a) => m effects a -> Final effects a
|
run :: (Effectful m, RunEffects effects a) => m effects a -> Final effects a
|
||||||
run = Effect.run . runEffects . lower
|
run = runEffects . lower
|
||||||
|
|
||||||
-- | A typeclass to run a computation to completion, interpreting each effect with some sensible defaults.
|
-- | A typeclass to run a computation to completion, interpreting each effect with some sensible defaults.
|
||||||
class RunEffects effects a where
|
class RunEffects effects a where
|
||||||
-- | The final result type of the computation, factoring in the results of any effects, e.g. pairing 'State' results with the final state, wrapping 'Fail' results in 'Either', etc.
|
-- | The final result type of the computation, factoring in the results of any effects, e.g. pairing 'State' results with the final state, wrapping 'Fail' results in 'Either', etc.
|
||||||
type Final effects a
|
type Final effects a
|
||||||
runEffects :: Eff effects a -> Eff '[] (Final effects a)
|
runEffects :: Eff effects a -> Final effects a
|
||||||
|
|
||||||
instance (RunEffect effect1 a, RunEffects (effect2 ': effects) (Result effect1 a)) => RunEffects (effect1 ': effect2 ': effects) a where
|
instance (RunEffect effect1 a, RunEffects effects (Result effect1 a)) => RunEffects (effect1 ': effects) a where
|
||||||
type Final (effect1 ': effect2 ': effects) a = Final (effect2 ': effects) (Result effect1 a)
|
type Final (effect1 ': effects) a = Final effects (Result effect1 a)
|
||||||
runEffects = runEffects . runEffect
|
runEffects = runEffects . runEffect
|
||||||
|
|
||||||
instance RunEffect effect a => RunEffects '[effect] a where
|
instance RunEffects '[] a where
|
||||||
type Final '[effect] a = Result effect a
|
type Final '[] a = a
|
||||||
runEffects = runEffect
|
runEffects = Effect.run
|
||||||
|
|
||||||
|
|
||||||
-- | A typeclass to interpret a single effect with some sensible defaults (defined per-effect).
|
-- | A typeclass to interpret a single effect with some sensible defaults (defined per-effect).
|
||||||
|
Loading…
Reference in New Issue
Block a user