From 79e5f02108953db29be29be6e9de803ad4b6982f Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Sun, 6 May 2018 14:16:40 -0400 Subject: [PATCH] Qualify Eff. --- src/Control/Effect.hs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Control/Effect.hs b/src/Control/Effect.hs index 7ed353a74..4f5755c42 100644 --- a/src/Control/Effect.hs +++ b/src/Control/Effect.hs @@ -12,10 +12,11 @@ module Control.Effect , handleState ) where -import Control.Monad.Effect +import qualified Control.Monad.Effect as Eff import Control.Monad.Effect.Reader import Control.Monad.Effect.Resumable import Control.Monad.Effect.State +import Prologue hiding (throwError) throwResumable :: (Member (Resumable exc) effects, Effectful m) => exc v -> m effects v throwResumable = raise . throwError @@ -24,24 +25,24 @@ resume :: (Member (Resumable exc) e, Effectful m) => m e a -> (forall v . (v -> resume m handle = raise (resumeError (lower m) (\yield -> lower . handle (raise . yield))) --- | Types wrapping 'Eff' actions. +-- | Types wrapping 'Eff.Eff' actions. -- --- Most instances of 'Effectful' will be derived using @-XGeneralizedNewtypeDeriving@, with these ultimately bottoming out on the instance for 'Eff' (for which 'raise' and 'lower' are simply the identity). Because of this, types can be nested arbitrarily deeply and still call 'raise'/'lower' just once to get at the (ultimately) underlying 'Eff'. +-- Most instances of 'Effectful' will be derived using @-XGeneralizedNewtypeDeriving@, with these ultimately bottoming out on the instance for 'Eff.Eff' (for which 'raise' and 'lower' are simply the identity). Because of this, types can be nested arbitrarily deeply and still call 'raise'/'lower' just once to get at the (ultimately) underlying 'Eff.Eff'. class Effectful m where -- | Raise an action in 'Eff' into an action in @m@. - raise :: Eff effects a -> m effects a + raise :: Eff.Eff effects a -> m effects a -- | Lower an action in @m@ into an action in 'Eff'. - lower :: m effects a -> Eff effects a + lower :: m effects a -> Eff.Eff effects a -instance Effectful Eff where +instance Effectful Eff.Eff where raise = id lower = id -- Handlers --- | Raise a handler on 'Eff' to a handler on some 'Effectful' @m@. -raiseHandler :: Effectful m => (Eff effectsA a -> Eff effectsB b) -> m effectsA a -> m effectsB b +-- | Raise a handler on 'Eff.Eff' to a handler on some 'Effectful' @m@. +raiseHandler :: Effectful m => (Eff.Eff effectsA a -> Eff.Eff effectsB b) -> m effectsA a -> m effectsB b raiseHandler handler = raise . handler . lower -- | Run a 'Reader' effect in an 'Effectful' context.