packages feed

monad-time-effectful 1.0.0.0 → 1.0.1.0

raw patch · 4 files changed

+21/−5 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Effectful.Time: runFixedStepTime :: forall (es :: [Effect]) a. IOE :> es => UTCTime -> NominalDiffTime -> Eff (Time ': es) a -> Eff es a
- Effectful.Time: [CurrentTime] :: Time m UTCTime
+ Effectful.Time: [CurrentTime] :: forall (a :: Type -> Type). Time a UTCTime
- Effectful.Time: [MonotonicTime] :: Time m Double
+ Effectful.Time: [MonotonicTime] :: forall (a :: Type -> Type). Time a Double
- Effectful.Time: data Time :: Effect
+ Effectful.Time: data Time (a :: Type -> Type) b
- Effectful.Time: runFrozenTime :: IOE :> es => UTCTime -> Eff (Time : es) a -> Eff es a
+ Effectful.Time: runFrozenTime :: forall (es :: [Effect]) a. IOE :> es => UTCTime -> Eff (Time ': es) a -> Eff es a
- Effectful.Time: runTime :: IOE :> es => Eff (Time : es) a -> Eff es a
+ Effectful.Time: runTime :: forall (es :: [Effect]) a. IOE :> es => Eff (Time ': es) a -> Eff es a

Files

CHANGELOG.md view
@@ -1,2 +1,5 @@+# monad-time-effectful-1.0.1.0 (2026-03-25)+* Add the `runFixedStepTime` handler.+ # monad-time-effectful-1.0.0.0 (2023-06-19) * Initial release.
README.md view
@@ -1,8 +1,7 @@ # monad-time-effectful -[![Build Status](https://github.com/haskell-effectful/monad-time-effectful/workflows/Haskell-CI/badge.svg?branch=master)](https://github.com/haskell-effectful/monad-time-effectful/actions?query=branch%3Amaster)+[![CI](https://github.com/haskell-effectful/monad-time-effectful/actions/workflows/haskell-ci.yml/badge.svg?branch=master)](https://github.com/haskell-effectful/monad-time-effectful/actions/workflows/haskell-ci.yml) [![Hackage](https://img.shields.io/hackage/v/monad-time-effectful.svg)](https://hackage.haskell.org/package/monad-time-effectful)-[![Dependencies](https://img.shields.io/hackage-deps/v/monad-time-effectful.svg)](https://packdeps.haskellers.com/feed?needle=andrzej@rybczak.net) [![Stackage LTS](https://www.stackage.org/package/monad-time-effectful/badge/lts)](https://www.stackage.org/lts/package/monad-time-effectful) [![Stackage Nightly](https://www.stackage.org/package/monad-time-effectful/badge/nightly)](https://www.stackage.org/nightly/package/monad-time-effectful) 
monad-time-effectful.cabal view
@@ -1,7 +1,7 @@-cabal-version:      2.4+cabal-version:      3.0 build-type:         Simple name:               monad-time-effectful-version:            1.0.0.0+version:            1.0.1.0 license:            MIT license-file:       LICENSE category:           Control@@ -16,7 +16,7 @@   CHANGELOG.md   README.md -tested-with: GHC ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.5 || ==9.6.2+tested-with: GHC == { 8.10.7, 9.0.2, 9.2.8, 9.4.8, 9.6.7, 9.8.4, 9.10.3, 9.12.2, 9.14.1 }  bug-reports: https://github.com/haskell-effectful/monad-time-effectful/issues source-repository head
src/Effectful/Time.hs view
@@ -10,6 +10,7 @@     -- ** Handlers   , runTime   , runFrozenTime+  , runFixedStepTime   ) where  import Control.Monad.IO.Class@@ -17,6 +18,7 @@ import Data.Time import Effectful import Effectful.Dispatch.Dynamic+import Effectful.State.Static.Local import GHC.Clock (getMonotonicTime)  -- | Provide the ability to use the 'MonadTime' instance of 'Eff'.@@ -39,6 +41,18 @@ runFrozenTime time = interpret $ \_ -> \case   CurrentTime -> pure time   MonotonicTime -> liftIO getMonotonicTime++-- | Run the 'Time' effect with a given starting time; time advances+-- by a fixed increment for every invocation of the 'CurrentTime'+-- operation. A negative increment will make the clock run backwards.+--+-- /Note:/ the 'MonotonicTime' operation works the same way as in+-- 'runTime'.+runFixedStepTime :: IOE :> es => UTCTime -> NominalDiffTime -> Eff (Time : es) a -> Eff es a+runFixedStepTime start diff =+  reinterpret_ (evalState start) $ \case+    CurrentTime -> state $ \s -> (s, diff `addUTCTime` s)+    MonotonicTime -> liftIO getMonotonicTime  ---------------------------------------- -- Orphan instance