packages feed

monad-extras 0.3.2.0 → 0.4.0.0

raw patch · 3 files changed

+17/−48 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Control.Concurrent.Delay: delayDays :: Integer -> IO ()
- Control.Concurrent.Delay: delayHours :: Integer -> IO ()
- Control.Concurrent.Delay: delayMicrosecs :: Integer -> IO ()
- Control.Concurrent.Delay: delayMillisecs :: Integer -> IO ()
- Control.Concurrent.Delay: delayMinutes :: Integer -> IO ()
- Control.Concurrent.Delay: delaySeconds :: Integer -> IO ()
+ Control.Monad.Extra: discard :: Monad m => a -> m ()
+ Control.Monad.Extra: label :: ContT r m (ContT r m a)
+ Control.Monad.Extra: liftMaybe :: MonadPlus m => Maybe a -> m a

Files

− Control/Concurrent/Delay.hs
@@ -1,46 +0,0 @@--- | Delay the current thread with an unbound number of milliseconds.--module Control.Concurrent.Delay-  (delayMicrosecs-  ,delayMillisecs-  ,delaySeconds-  ,delayMinutes-  ,delayHours-  ,delayDays-  ) where--import Control.Concurrent---- | Suspends the current thread for a given number of microseconds.------ There is no guarantee that the thread will be rescheduled promptly--- when the delay has expired, but the thread will never continue to--- run earlier than specified.-delayMicrosecs :: Integer -> IO ()-delayMicrosecs microsecs-  | microsecs <= fromIntegral maxMicrosecs = threadDelay (fromIntegral microsecs)-  | otherwise = do-    threadDelay maxMicrosecs-    delayMicrosecs (microsecs - fromIntegral maxMicrosecs)--  where maxMicrosecs = maxBound :: Int---- | Delay the current thread for at least n milliseconds.-delayMillisecs :: Integer -> IO ()-delayMillisecs = delayMicrosecs . (*1000)---- | Delay the current thread for at least n seconds.-delaySeconds :: Integer -> IO ()-delaySeconds = delayMillisecs . (* 1000)---- | Delay the current thread for at least n minutes.-delayMinutes :: Integer -> IO ()-delayMinutes = delaySeconds . (*60)---- | Delay the current thread for at least n hours.-delayHours :: Integer -> IO ()-delayHours = delayMinutes . (*60)---- | Delay the current thread for at least n days.-delayDays :: Integer -> IO ()-delayDays = delayHours . (*24)
Control/Monad/Extra.hs view
@@ -1,6 +1,7 @@ module Control.Monad.Extra where  import Control.Applicative+import Control.Monad import Control.Monad.Trans.Cont import Control.Monad.IO.Class @@ -8,6 +9,10 @@ skip :: Monad m => m () skip = return () +-- | Discards a value+discard :: Monad m => a -> m ()+discard _ = return ()+ -- | Synonym for @pure ()@. obvious :: Applicative f => f () obvious = pure ()@@ -47,6 +52,16 @@ doCallCC :: Monad m => ((r -> ContT r m b) -> ContT r m r) -> m r doCallCC = flip runContT return . callCC +-- | Return a continuation that one can jump back to within 'ContT'.+--+-- >>> flip runContT return $ do { k <- label; ...; k }+label :: ContT r m (ContT r m a)+label = callCC $ \k -> let m = k m in return m+ -- | Short-hand for @liftIO@. io :: MonadIO m => IO a -> m a io = liftIO++-- | Lift a 'Maybe' value into the 'MaybeT' monad transformer.+liftMaybe :: (MonadPlus m) => Maybe a -> m a+liftMaybe = maybe mzero return
monad-extras.cabal view
@@ -1,5 +1,5 @@ name:           monad-extras-version:        0.3.2.0+version:        0.4.0.0 synopsis:       Extra utility functions for working with monads -- description: homepage:       http://github.com/jwiegley/monad-extras@@ -15,7 +15,7 @@ library     default-language: Haskell98     exposed-modules:-        Control.Monad.Extra, Control.Concurrent.Delay+        Control.Monad.Extra     build-depends:         base >= 4 && < 5       , transformers