polysemy-chronos 0.3.0.0 → 0.4.0.0
raw patch · 5 files changed
+92/−93 lines, 5 filesdep ~incipit-corePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: incipit-core
API changes (from Hackage documentation)
- Polysemy.Chronos.Time: interpretTimeChronos :: Member (Embed IO) r => InterpreterFor ChronosTime r
- Polysemy.Chronos.Time: interpretTimeChronosAt :: Member (Embed IO) r => Time -> InterpreterFor ChronosTime r
- Polysemy.Chronos.Time: interpretTimeChronosConstant :: Member (Embed IO) r => Time -> InterpreterFor ChronosTime r
- Polysemy.Chronos.Time: interpretTimeChronosConstantNow :: Member (Embed IO) r => InterpreterFor ChronosTime r
- Polysemy.Chronos.Time: type ChronosTime = Time Time Date
+ Polysemy.Chronos.Interpreter.Time: interpretTimeChronos :: Member (Embed IO) r => InterpreterFor ChronosTime r
+ Polysemy.Chronos.Interpreter.Time: interpretTimeChronosAt :: Member (Embed IO) r => Time -> InterpreterFor ChronosTime r
+ Polysemy.Chronos.Interpreter.Time: interpretTimeChronosConstant :: Member (Embed IO) r => Time -> InterpreterFor ChronosTime r
+ Polysemy.Chronos.Interpreter.Time: interpretTimeChronosConstantNow :: Member (Embed IO) r => InterpreterFor ChronosTime r
+ Polysemy.Chronos.Interpreter.Time: type ChronosTime = Time Time Date
Files
- lib/Polysemy/Chronos.hs +5/−6
- lib/Polysemy/Chronos/Interpreter/Time.hs +82/−0
- lib/Polysemy/Chronos/Time.hs +0/−82
- polysemy-chronos.cabal +3/−3
- test/Polysemy/Chronos/ChronosTimeTest.hs +2/−2
lib/Polysemy/Chronos.hs view
@@ -1,16 +1,15 @@-{-|-This package provides an interpreter implementation and instances for "Chronos" of the 'Polysemy.Time' library.--}+-- |This package provides "Chronos" based interpreters and instances for the effect and classes defined in+-- "Polysemy.Time". module Polysemy.Chronos ( -- * Interpreters- module Polysemy.Chronos.Time,+ module Polysemy.Chronos.Interpreter.Time, ) where -import Polysemy.Chronos.Orphans ()-import Polysemy.Chronos.Time (+import Polysemy.Chronos.Interpreter.Time ( ChronosTime, interpretTimeChronos, interpretTimeChronosAt, interpretTimeChronosConstant, interpretTimeChronosConstantNow, )+import Polysemy.Chronos.Orphans ()
+ lib/Polysemy/Chronos/Interpreter/Time.hs view
@@ -0,0 +1,82 @@+{-# options_haddock prune #-}++-- |Time interpreters for "Chronos", Internal+module Polysemy.Chronos.Interpreter.Time where++import qualified Chronos as Chronos+import Chronos (Timespan (Timespan), dateToDay, dayToDate, dayToTimeMidnight, timeToDayTruncate)+import Polysemy.Time.At (interceptTimeAt, interceptTimeConstant, interceptTimeConstantNow)+import qualified Polysemy.Time.Effect.Time as Core+import Polysemy.Time.Effect.Time (Time)+import Polysemy.Time.Sleep (tSleep)++import Polysemy.Chronos.Orphans ()++-- |Convenience alias for "Chronos".+type ChronosTime =+ Time Chronos.Time Chronos.Date++now ::+ Member (Embed IO) r =>+ Sem r Chronos.Time+now =+ embed Chronos.now++timeToDate :: Chronos.Time -> Chronos.Date+timeToDate =+ dayToDate . timeToDayTruncate++dateToTime :: Chronos.Date -> Chronos.Time+dateToTime =+ dayToTimeMidnight . dateToDay++-- |Interpret 'Time' with the types from "Chronos".+interpretTimeChronos ::+ Member (Embed IO) r =>+ InterpreterFor ChronosTime r+interpretTimeChronos =+ interpret \case+ Core.Now ->+ now+ Core.Today ->+ timeToDate <$> now+ Core.Sleep t ->+ tSleep t+ Core.SetTime _ ->+ unit+ Core.Adjust _ ->+ unit+ Core.SetDate _ ->+ unit+{-# inline interpretTimeChronos #-}++-- |Interpret 'Time' with the types from "Chronos", customizing the current time at the start of interpretation.+interpretTimeChronosAt ::+ Member (Embed IO) r =>+ Chronos.Time ->+ InterpreterFor ChronosTime r+interpretTimeChronosAt t =+ interpretTimeChronos . interceptTimeAt @Timespan t+{-# inline interpretTimeChronosAt #-}++-- |Interpret 'Time' with the types from "Chronos", customizing the current time to be constant.+interpretTimeChronosConstant ::+ Member (Embed IO) r =>+ Chronos.Time ->+ InterpreterFor ChronosTime r+interpretTimeChronosConstant t =+ interpretTimeChronos . interceptTimeConstant t+{-# inline interpretTimeChronosConstant #-}++-- |Interpret 'Time' with the types from "Chronos", customizing the current time to be constantly the time at the+-- start of interpretation.+interpretTimeChronosConstantNow ::+ Member (Embed IO) r =>+ InterpreterFor ChronosTime r+interpretTimeChronosConstantNow =+ interpretTimeChronos . interceptTimeConstantNow @Chronos.Time+{-# inline interpretTimeChronosConstantNow #-}++negateTimespan :: Timespan -> Timespan+negateTimespan (Timespan t) =+ Timespan (-t)
− lib/Polysemy/Chronos/Time.hs
@@ -1,82 +0,0 @@-{-# options_haddock prune #-}---- |Time interpreters for "Chronos", Internal-module Polysemy.Chronos.Time where--import qualified Chronos as Chronos-import Chronos (Timespan (Timespan), dateToDay, dayToDate, dayToTimeMidnight, timeToDayTruncate)-import Polysemy.Time.At (interceptTimeAt, interceptTimeConstant, interceptTimeConstantNow)-import qualified Polysemy.Time.Data.Time as Core-import Polysemy.Time.Data.Time (Time)-import Polysemy.Time.Sleep (tSleep)--import Polysemy.Chronos.Orphans ()---- |Convenience alias for "Chronos".-type ChronosTime =- Time Chronos.Time Chronos.Date--now ::- Member (Embed IO) r =>- Sem r Chronos.Time-now =- embed Chronos.now--timeToDate :: Chronos.Time -> Chronos.Date-timeToDate =- dayToDate . timeToDayTruncate--dateToTime :: Chronos.Date -> Chronos.Time-dateToTime =- dayToTimeMidnight . dateToDay---- |Interpret 'Time' with the types from "Chronos".-interpretTimeChronos ::- Member (Embed IO) r =>- InterpreterFor ChronosTime r-interpretTimeChronos =- interpret \case- Core.Now ->- now- Core.Today ->- timeToDate <$> now- Core.Sleep t ->- tSleep t- Core.SetTime _ ->- unit- Core.Adjust _ ->- unit- Core.SetDate _ ->- unit-{-# inline interpretTimeChronos #-}---- |Interpret 'Time' with the types from "Chronos", customizing the current time at the start of interpretation.-interpretTimeChronosAt ::- Member (Embed IO) r =>- Chronos.Time ->- InterpreterFor ChronosTime r-interpretTimeChronosAt t =- interpretTimeChronos . interceptTimeAt @Timespan t-{-# inline interpretTimeChronosAt #-}---- |Interpret 'Time' with the types from "Chronos", customizing the current time to be constant.-interpretTimeChronosConstant ::- Member (Embed IO) r =>- Chronos.Time ->- InterpreterFor ChronosTime r-interpretTimeChronosConstant t =- interpretTimeChronos . interceptTimeConstant t-{-# inline interpretTimeChronosConstant #-}---- |Interpret 'Time' with the types from "Chronos", customizing the current time to be constantly the time at the--- start of interpretation.-interpretTimeChronosConstantNow ::- Member (Embed IO) r =>- InterpreterFor ChronosTime r-interpretTimeChronosConstantNow =- interpretTimeChronos . interceptTimeConstantNow @Chronos.Time-{-# inline interpretTimeChronosConstantNow #-}--negateTimespan :: Timespan -> Timespan-negateTimespan (Timespan t) =- Timespan (-t)
polysemy-chronos.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: polysemy-chronos-version: 0.3.0.0+version: 0.4.0.0 synopsis: Polysemy-time Interpreters for Chronos description: Please see the readme on Github at <https://github.com/tek/polysemy-time> category: Time@@ -22,8 +22,8 @@ library exposed-modules: Polysemy.Chronos+ Polysemy.Chronos.Interpreter.Time Polysemy.Chronos.Orphans- Polysemy.Chronos.Time hs-source-dirs: lib default-extensions:@@ -88,7 +88,7 @@ build-depends: base ==4.* , chronos >=1.1.1 && <1.2- , incipit-core >=0.1+ , incipit-core >=0.2 , polysemy-time mixins: base hiding (Prelude)
test/Polysemy/Chronos/ChronosTimeTest.hs view
@@ -3,11 +3,11 @@ import qualified Chronos as Chronos import Polysemy.Test (UnitTest, assert, assertEq, runTestAuto) import Polysemy.Time.Calendar (year)-import qualified Polysemy.Time.Data.Time as Time import Polysemy.Time.Data.TimeUnit (Seconds (Seconds))+import qualified Polysemy.Time.Effect.Time as Time import Polysemy.Chronos (interpretTimeChronos)-import Polysemy.Chronos.Time (interpretTimeChronosAt)+import Polysemy.Chronos.Interpreter.Time (interpretTimeChronosAt) test_chronosTime :: UnitTest test_chronosTime =