packages feed

contstuff 1.2.3 → 1.2.4

raw patch · 3 files changed

+34/−20 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Control.ContStuff.Trans: liftMaybe :: Monad m => m (Maybe a) -> MaybeT r m a
+ Control.ContStuff.Classes: class LiftFunctor t where { type family InnerFunctor t :: * -> *; }
+ Control.ContStuff.Classes: liftF :: (LiftFunctor t, Monad m) => m (InnerFunctor t a) -> t m a
+ Control.ContStuff.Trans: instance LiftFunctor (ChoiceT r i)
+ Control.ContStuff.Trans: instance LiftFunctor (EitherT r e)
+ Control.ContStuff.Trans: instance LiftFunctor (MaybeT r)

Files

Control/ContStuff/Classes.hs view
@@ -23,6 +23,8 @@       HasExceptions(..),       bracket, bracket_, catch, finally, forbid, handle, raiseUnless,       raiseWhen, require,+      -- ** Functor lifting+      LiftFunctor(..),       -- ** State       -- *** Reading       Readable(..),@@ -208,6 +210,20 @@       Monad m, Monad (t m), MonadTrans t ) =>     m Bool -> t m () require = raiseUnless () . lift+++------------------+-- Lift functor --+------------------++-- | Type class for lifting functor computations.++class LiftFunctor t where+    -- | Inner functor.+    type InnerFunctor t :: * -> *++    -- | Unwrap inner functor.+    liftF :: Monad m => m (InnerFunctor t a) -> t m a   -----------
Control/ContStuff/Trans.hs view
@@ -30,7 +30,7 @@        -- ** Exceptions       EitherT(..),-      runEitherT, evalEitherT, liftMaybe, modifyEitherT, testEitherT,+      runEitherT, evalEitherT, modifyEitherT, testEitherT,        MaybeT(..),       runMaybeT, evalMaybeT, modifyMaybeT, testMaybeT,@@ -101,6 +101,10 @@         ChoiceT $ \fold z k ->             c (\x y k -> fold x (f y) k) z k +instance LiftFunctor (ChoiceT r i) where+    type InnerFunctor (ChoiceT r i) = []+    liftF c = lift c >>= choice+ instance Monad (ChoiceT r i m) where     return x = ChoiceT $ \fold z k -> fold z x k     ChoiceT c >>= f =@@ -302,14 +306,18 @@     forkIO (EitherT c) = lift . forkIO $ c deReturn deReturn     forkOS (EitherT c) = lift . forkOS $ c deReturn deReturn +instance Functor (EitherT r e m) where+    fmap f (EitherT c) =+        EitherT $ \k expk -> c (k . f) expk+ instance HasExceptions (EitherT r e m) where     type Exception (EitherT r e m) = e     raise exp = EitherT $ \_ expk -> expk exp     try (EitherT c) = EitherT $ \k _ -> c (k . Right) (k . Left) -instance Functor (EitherT r e m) where-    fmap f (EitherT c) =-        EitherT $ \k expk -> c (k . f) expk+instance LiftFunctor (EitherT r e) where+    type InnerFunctor (EitherT r e) = Either e+    liftF c = EitherT $ \k expk -> c >>= either expk k  instance Monad (EitherT r e m) where     return x = EitherT $ \k _ -> k x@@ -412,6 +420,10 @@     fmap f (MaybeT c) =         MaybeT $ \just noth -> c (just . f) noth +instance LiftFunctor (MaybeT r) where+    type InnerFunctor (MaybeT r) = Maybe+    liftF c = MaybeT $ \just nothing -> c >>= maybe nothing just+ instance Monad (MaybeT r m) where     return x = MaybeT $ \just _ -> just x     MaybeT c >>= f =@@ -447,15 +459,6 @@ evalMaybeT (MaybeT c) = c (pure . Just) (pure Nothing)  --- | Lift a computation which returns a 'Maybe'-wrapped value to a--- 'MaybeT' computation.--liftMaybe :: Monad m => m (Maybe a) -> MaybeT r m a-liftMaybe c =-    MaybeT $ \just nothing ->-        c >>= maybe nothing just-- -- | Modify the result of a 'MaybeT' computation along the way.  modifyMaybeT :: Functor m => (r -> r) -> MaybeT r m ()@@ -572,17 +575,13 @@     forkOS (StateT c) = StateT $ \k s0 -> forkOS (c deReturn s0) >>= flip k s0  instance Functor (StateT r s m) where-    {-# INLINE fmap #-}     fmap f (StateT c) = StateT $ \k -> c (k . f)  instance Monad (StateT r s m) where-    {-# INLINE return #-}     return x = StateT ($ x)-    {-# INLINE (>>=) #-}     StateT c >>= f = StateT $ \k -> c (\x -> getStateT (f x) k)  instance MonadIO m => MonadIO (StateT r s m) where-    {-# INLINE liftIO #-}     liftIO = lift . liftIO  instance Alternative m => MonadPlus (StateT r s m) where@@ -598,7 +597,6 @@     putLazy s1 = StateT $ \k -> const (k () s1)  instance MonadTrans (StateT r s) where-    {-# INLINE lift #-}     lift c = StateT $ \k s0 -> c >>= flip k s0  instance Alternative m => Writable (StateT r s m) r where
contstuff.cabal view
@@ -1,5 +1,5 @@ Name:          contstuff-Version:       1.2.3+Version:       1.2.4 Category:      Control, Monads Synopsis:      Fast, easy to use CPS-based monad transformers Maintainer:    Ertugrul Söylemez <es@ertes.de>@@ -29,7 +29,7 @@     Build-depends:         base >= 4 && <= 5,         transformers >= 0.2.2.0-    GHC-Options: -W -O2+    GHC-Options: -W     Exposed-modules:         Control.ContStuff         Control.ContStuff.Classes