packages feed

monad-time 0.3.1.0 → 0.4.0.0

raw patch · 5 files changed

+17/−18 lines, 5 filesdep ~base

Dependency ranges changed: base

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+# monad-time-0.4.0.0 (2022-07-05)+* Added `monotonicTime` to `MonadTime`+* Removed the `MonadTime` instance for `ReaderT UTCTime`+ # monad-time-0.3.1.0 (2018-04-09) * Restored compatibility with GHC versions < 7.10   ([#4](https://github.com/scrive/monad-time/issues/4)).
README.md view
@@ -1,4 +1,3 @@ # monad-time [![Hackage version](https://img.shields.io/hackage/v/monad-time.svg?label=Hackage)](https://hackage.haskell.org/package/monad-time) [![Build Status](https://secure.travis-ci.org/scrive/monad-time.svg?branch=master)](http://travis-ci.org/scrive/monad-time) -A `MonadTime` type class for monads which carry the notion of the-current time.+`MonadTime` type class for monads which make it possible to measure time.
monad-time.cabal view
@@ -1,5 +1,5 @@ name:                monad-time-version:             0.3.1.0+version:             0.4.0.0 synopsis:            Type class for monads which carry                      the notion of the current time. description:         'MonadTime' type class for monads@@ -16,8 +16,7 @@ build-type:          Simple cabal-version:       >=1.10 extra-source-files:  README.md CHANGELOG.md-tested-with:         GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3,-                     GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.1+tested-with:         GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.3  source-repository head   type:     git@@ -26,7 +25,7 @@ library   exposed-modules:   Control.Monad.Time -  build-depends:     base < 5,+  build-depends:     base >=4.13 && < 5,                      mtl,                      time 
src/Control/Monad/Time.hs view
@@ -7,23 +7,18 @@ module Control.Monad.Time (MonadTime(..)) where  import Control.Monad.Trans-import Control.Monad.Reader (ReaderT, ask) import Data.Time+import GHC.Clock (getMonotonicTime) --- | Class of monads which carry the notion of the current time.+-- | Class of monads which make it possible to measure time. class Monad m => MonadTime m where   currentTime :: m UTCTime+  monotonicTime :: m Double  -- | Base instance for IO. instance MonadTime IO where   currentTime = getCurrentTime---- | This is @ReaderT UTCTime@ on purpose, to avoid breaking--- downstream.------ @since 0.3.0.0-instance {-# OVERLAPPING #-} Monad m => MonadTime (ReaderT UTCTime m) where-  currentTime = ask+  monotonicTime = getMonotonicTime  -- | Generic, overlapping instance. instance {-# OVERLAPPABLE #-} (@@ -32,3 +27,4 @@   , Monad (t m)   ) => MonadTime (t m) where     currentTime = lift currentTime+    monotonicTime = lift monotonicTime
test/Main.hs view
@@ -12,6 +12,7 @@   -- Test that generic MonadTrans instance works.   runReaderT currentTime 'x' >>= print   evalStateT (runReaderT currentTime 'x') 'y' >>= print-  -- Test that ReaderT UTCTime instance works-  now <- getCurrentTime-  runReaderT currentTime now >>= print++  monotonicTime >>= print+  runReaderT monotonicTime 'x' >>= print+  evalStateT (runReaderT monotonicTime 'x') 'y' >>= print