monad-time 0.1 → 0.2
raw patch · 4 files changed
+46/−18 lines, 4 filesdep +monad-timedep ~base
Dependencies added: monad-time
Dependency ranges changed: base
Files
- monad-time.cabal +21/−3
- src/Control/Monad/Time.hs +12/−0
- src/Control/Monad/Time/Instances.hs +0/−15
- test/Main.hs +13/−0
monad-time.cabal view
@@ -1,6 +1,7 @@ name: monad-time-version: 0.1+version: 0.2 synopsis: Type class for monads which carry the notion of the current time.+description: 'MonadTime' type class for monads which carry the notion of the current time. homepage: https://github.com/scrive/monad-time license: BSD3 license-file: LICENSE@@ -9,14 +10,31 @@ category: Control build-type: Simple cabal-version: >=1.10+tested-with: GHC==7.4.2, GHC==7.6.3, GHC==7.8.4, GHC==7.10.3, GHC==8.0.1 +source-repository head+ type: git+ location: git@github.com:scrive/monad-time.git+ library- exposed-modules: Control.Monad.Time,- Control.Monad.Time.Instances+ exposed-modules: Control.Monad.Time build-depends: base < 5, mtl, time hs-source-dirs: src++ ghc-options: -Wall+ default-language: Haskell2010++test-suite monad-time-test+ type: exitcode-stdio-1.0+ main-is: Main.hs+ hs-source-dirs: test+ default-language: Haskell2010+ build-depends: base,+ mtl,+ monad-time,+ time
src/Control/Monad/Time.hs view
@@ -1,3 +1,6 @@+{-# OPTIONS_GHC -fno-warn-deprecated-flags #-}+{-# LANGUAGE FlexibleContexts, FlexibleInstances, OverlappingInstances+ , UndecidableInstances #-} module Control.Monad.Time (MonadTime(..)) where import Control.Monad.Trans@@ -7,5 +10,14 @@ class Monad m => MonadTime m where currentTime :: m UTCTime +-- | Base instance for IO. instance MonadTime IO where currentTime = getCurrentTime++-- | Generic, overlapping instance.+instance (+ MonadTime m+ , MonadTrans t+ , Monad (t m)+ ) => MonadTime (t m) where+ currentTime = lift currentTime
− src/Control/Monad/Time/Instances.hs
@@ -1,15 +0,0 @@-{-# LANGUAGE FlexibleContexts, FlexibleInstances, OverlappingInstances- , UndecidableInstances #-}-module Control.Monad.Time.Instances () where--import Control.Monad.Trans--import Control.Monad.Time---- | Generic, overlapping instance.-instance (- MonadTime m- , MonadTrans t- , Monad (t m)- ) => MonadTime (t m) where- currentTime = lift currentTime
+ test/Main.hs view
@@ -0,0 +1,13 @@+module Main (main) where++import Control.Monad.Reader+import Control.Monad.State++import Control.Monad.Time++main :: IO ()+main = do+ currentTime >>= print+ -- Test that generic MonadTrans instance works.+ runReaderT currentTime 'x' >>= print+ evalStateT (runReaderT currentTime 'x') 'y' >>= print