packages feed

tiempo 0.0.0.0 → 0.0.1.0

raw patch · 3 files changed

+31/−22 lines, 3 filesdep ~basedep ~time

Dependency ranges changed: base, time

Files

src/Tiempo.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE DeriveGeneric      #-} module Tiempo   ( TimeInterval   -- * TimeInterval to different units and types@@ -16,9 +17,6 @@   , agoTime   , ago -  -- * Concurrency Utilities-  , threadDelay-   -- * Unit functions   , microSeconds   , milliSeconds@@ -27,23 +25,22 @@   , hours   , days ) where -import qualified Control.Concurrent as Concurrent (threadDelay)-import           Control.DeepSeq    (NFData (..))-import           Data.Time          (NominalDiffTime, UTCTime, addUTCTime,-                                     getCurrentTime)-import           Data.Typeable      (Typeable)+import Control.DeepSeq (NFData (..))+import Data.Time       (NominalDiffTime, UTCTime, addUTCTime, getCurrentTime)+import Data.Typeable   (Typeable)+import GHC.Generics    (Generic)  --------------------------------------------------------------------------------  data  TimeUnit   = Days | Hours | Minutes | Seconds | Millis | Micros-  deriving (Eq, Show, Typeable)+  deriving (Eq, Show, Typeable, Generic)  instance NFData TimeUnit  data TimeInterval   = TimeInterval !TimeUnit !Int-  deriving (Eq, Show)+  deriving (Eq, Show, Typeable, Generic)  instance NFData TimeInterval where   rnf (TimeInterval unit n) =@@ -112,14 +109,6 @@ ago :: TimeInterval -> IO UTCTime ago interval = agoTime interval `fmap` getCurrentTime {-# INLINE ago #-}-------------------------------------------------------------------------------------- | Like @Control.Concurrent.threadDelay@ but accepts a--- @TimeInterval@ instead of an Int-threadDelay :: TimeInterval -> IO ()-threadDelay = Concurrent.threadDelay . toMicroSeconds-{-# INLINE threadDelay #-}  -------------------------------------------------------------------------------- 
+ src/Tiempo/Concurrent.hs view
@@ -0,0 +1,19 @@+module Tiempo.Concurrent (threadDelay, timeout) where++import qualified Control.Concurrent as Concurrent (threadDelay)+import qualified System.Timeout     as Timeout (timeout)++import Tiempo (TimeInterval, toMicroSeconds)++-- | Like @Control.Concurrent.threadDelay@ but accepts a+-- @TimeInterval@ as an argument instead of an Int+threadDelay :: TimeInterval -> IO ()+threadDelay = Concurrent.threadDelay . toMicroSeconds+{-# INLINE threadDelay #-}+++-- | Like @System.Timeout@ but accepts a @TimeInterval@ as an argument+-- instead of an Int+timeout :: TimeInterval -> IO a -> IO (Maybe a)+timeout = Timeout.timeout . toMicroSeconds+{-# INLINE timeout #-}
tiempo.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                tiempo-version:             0.0.0.0+version:             0.0.1.0 synopsis:            Specify time intervals in different units (secs, mins, hours, etc.) description:         A sane and simple API that sits on top of the time library; it allows the creation                      of time intervals and provides to manipulate time using them.@@ -17,12 +17,13 @@  library   exposed-modules:-        Tiempo+        Tiempo,+        Tiempo.Concurrent   -- other-modules:   -- other-extensions:   build-depends:-        base >=4.6 && <4.7,+        base >=4.6 && <4.8,         deepseq >= 1.3 && <1.4,-        time+        time >=1.4.1 && <1.5   hs-source-dirs:      src   default-language:    Haskell2010