packages feed

extensible-effects 2.6.1.1 → 2.6.2.0

raw patch · 4 files changed

+42/−4 lines, 4 filesdep +transformersPVP ok

version bump matches the API change (PVP)

Dependencies added: transformers

API changes (from Hackage documentation)

Files

README.md view
@@ -226,7 +226,34 @@  ## Integration with IO -*work in progress*+`IO` as well as any other monad can be used as a base type for `Lift` effect.+There may be at most one instance of `Lift` effect in the effects list, and it+must be handled the last. `Control.Eff.Lift` exports `runLift` handler and+`lift` function, that provides an ability to run arbitrary monadic actions.+Also, there are convenient type aliases, that allow for shorter type constraints.++```haskell+f :: IO ()+f = runLift $ do printHello+                 printWorld++-- These two functions' types are equivalent.++printHello :: SetMember Lift (Lift IO) r => Eff r ()+printHello = lift (putStr "Hello")++printWorld :: Lifted IO r => Eff r ()+printWorld = lift (putStrLn " world!")+```++Note that, since `Lift` is a terminal effect, you do not need to use `run` to+extract pure value. Instead, `runLift` returns a value wrapped in whatever monad+you chose to use.++In addition, `Lift` effect provides `MonadBase`, `MonadBaseControl`, and `MonadIO`+instances, that may be useful, especially with packages like [lifted-base](http://hackage.haskell.org/package/lifted-base),+[lifted-async](http://hackage.haskell.org/package/lifted-async), and other+code that uses those typeclasses.  ## Integration with Monad Transformers 
extensible-effects.cabal view
@@ -6,7 +6,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             2.6.1.1+version:             2.6.2.0  -- A short (one-line) description of the package. synopsis:            An Alternative to Monad Transformers@@ -137,6 +137,9 @@                ,       transformers-base == 0.4.*                        -- For MonadBaseControl                ,       monad-control >= 1.0 && < 1.1+  if impl(ghc < 8.0)+                       -- For MonadIO+     build-depends:    transformers >= 0.2.0.0    -- Directories containing source files.   hs-source-dirs:      src
src/Control/Eff/Internal.hs view
@@ -31,6 +31,7 @@ import qualified Control.Arrow as A import qualified Control.Category as C import Control.Monad.Base (MonadBase(..))+import Control.Monad.IO.Class (MonadIO(..)) import Control.Monad.Trans.Control (MonadBaseControl(..)) import safe Data.OpenUnion import safe Data.FTCQueue@@ -167,7 +168,13 @@ instance (MonadBase m m)  => MonadBaseControl m (Eff '[Lift m]) where     type StM (Eff '[Lift m]) a = a     liftBaseWith f = lift (f runLift)+    {-# INLINE liftBaseWith #-}     restoreM = return+    {-# INLINE restoreM #-}++instance (MonadIO m, SetMember Lift (Lift m) r) => MonadIO (Eff r) where+    liftIO = lift . liftIO+    {-# INLINE liftIO #-}  -- | Send a request and wait for a reply (resulting in an effectful -- computation).
test/Control/Eff/Trace/Test.hs view
@@ -33,9 +33,10 @@  case_Trace_tMd :: Assertion case_Trace_tMd = do-  actual <- catchOutput tMd+  (actualResult, actualOutput) <- catchOutput tMd   assertEqual "Trace: higher-order effectful function"-    (map (+ val) input, unlines $ map (("mapMdebug: " ++) . show) input) actual+    (map (+ val) input, map (("mapMdebug: " ++) . show) input)+    (actualResult, lines actualOutput)   where     val = (10::Int)     input = [1..5]