packages feed

polysemy-time 0.2.0.1 → 0.2.0.2

raw patch · 16 files changed

+113/−15 lines, 16 filesdep ~polysemyPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: polysemy

API changes (from Hackage documentation)

- Polysemy.Time.Debug: dbg :: HasCallStack => Monad m => Text -> m ()
- Polysemy.Time.Debug: dbgs :: HasCallStack => Monad m => Show a => a -> m ()
- Polysemy.Time.Debug: dbgsWith :: HasCallStack => Monad m => Show a => Text -> a -> m ()
- Polysemy.Time.Debug: dbgs_ :: HasCallStack => Monad m => Show a => a -> m a
- Polysemy.Time.Debug: debugPrint :: SrcLoc -> Text -> IO ()
- Polysemy.Time.Debug: debugPrintWithLoc :: Monad m => SrcLoc -> Text -> m ()
- Polysemy.Time.Debug: srcLoc :: CallStack -> SrcLoc
- Polysemy.Time.Debug: tr :: HasCallStack => Text -> a -> a
- Polysemy.Time.Debug: trs :: Show a => HasCallStack => a -> a
- Polysemy.Time.Debug: trs' :: Show b => HasCallStack => b -> a -> a
- Polysemy.Time.Ghc: now :: Member (Embed IO) r => Sem r UTCTime
- Polysemy.Time.Orphans: instance Torsor.Additive Data.Time.Clock.Internal.NominalDiffTime.NominalDiffTime
- Polysemy.Time.Orphans: instance Torsor.Torsor Data.Time.Clock.Internal.UTCTime.UTCTime Data.Time.Clock.Internal.NominalDiffTime.NominalDiffTime
- Polysemy.Time.Sleep: tSleep :: Member (Embed IO) r => TimeUnit t => t -> Sem r ()
- Polysemy.Time.Sleep: uSleep :: Member (Embed IO) r => MicroSeconds -> Sem r ()
+ Polysemy.Time: diff :: forall dt u i1 i2. TimeUnit u => Torsor dt u => Instant i1 dt => Instant i2 dt => i1 -> i2 -> u
- Polysemy.Time: adjust :: forall t_aw9d d_aw9g r_awed u1_Xw9f u2_Xw9h. (MemberWithError (Time t_aw9d d_aw9g) r_awed, AddTimeUnit t_aw9d u1_Xw9f u2_Xw9h) => u1_Xw9f -> Sem r_awed ()
+ Polysemy.Time: adjust :: forall t d u1 u2 r. AddTimeUnit t u1 u2 => Member (Time t d) r => u1 -> Sem r ()
- Polysemy.Time: now :: forall t_aw90 d_aw91 r_awe7. MemberWithError (Time t_aw90 d_aw91) r_awe7 => Sem r_awe7 t_aw90
+ Polysemy.Time: now :: forall t d r. Member (Time t d) r => Sem r t
- Polysemy.Time: setDate :: forall t_aw9j d_aw9i r_awef. MemberWithError (Time t_aw9j d_aw9i) r_awef => d_aw9i -> Sem r_awef ()
+ Polysemy.Time: setDate :: forall t d r. Member (Time t d) r => d -> Sem r ()
- Polysemy.Time: setTime :: forall t_aw9a d_aw9b r_aweb. MemberWithError (Time t_aw9a d_aw9b) r_aweb => t_aw9a -> Sem r_aweb ()
+ Polysemy.Time: setTime :: forall t d r. Member (Time t d) r => t -> Sem r ()
- Polysemy.Time: sleep :: forall t_aw97 d_aw98 r_awe9 u_Xw97. (MemberWithError (Time t_aw97 d_aw98) r_awe9, TimeUnit u_Xw97) => u_Xw97 -> Sem r_awe9 ()
+ Polysemy.Time: sleep :: forall t d u r. TimeUnit u => Member (Time t d) r => u -> Sem r ()
- Polysemy.Time: today :: forall t_aw93 d_aw94 r_awe8. MemberWithError (Time t_aw93 d_aw94) r_awe8 => Sem r_awe8 d_aw94
+ Polysemy.Time: today :: forall t d r. Member (Time t d) r => Sem r d
- Polysemy.Time.Data.Time: adjust :: forall t_aw9d d_aw9g r_awed u1_Xw9f u2_Xw9h. (MemberWithError (Time t_aw9d d_aw9g) r_awed, AddTimeUnit t_aw9d u1_Xw9f u2_Xw9h) => u1_Xw9f -> Sem r_awed ()
+ Polysemy.Time.Data.Time: adjust :: forall t d u1 u2 r. AddTimeUnit t u1 u2 => Member (Time t d) r => u1 -> Sem r ()
- Polysemy.Time.Data.Time: now :: forall t_aw90 d_aw91 r_awe7. MemberWithError (Time t_aw90 d_aw91) r_awe7 => Sem r_awe7 t_aw90
+ Polysemy.Time.Data.Time: now :: forall t d r. Member (Time t d) r => Sem r t
- Polysemy.Time.Data.Time: setDate :: forall t_aw9j d_aw9i r_awef. MemberWithError (Time t_aw9j d_aw9i) r_awef => d_aw9i -> Sem r_awef ()
+ Polysemy.Time.Data.Time: setDate :: forall t d r. Member (Time t d) r => d -> Sem r ()
- Polysemy.Time.Data.Time: setTime :: forall t_aw9a d_aw9b r_aweb. MemberWithError (Time t_aw9a d_aw9b) r_aweb => t_aw9a -> Sem r_aweb ()
+ Polysemy.Time.Data.Time: setTime :: forall t d r. Member (Time t d) r => t -> Sem r ()
- Polysemy.Time.Data.Time: sleep :: forall t_aw97 d_aw98 r_awe9 u_Xw97. (MemberWithError (Time t_aw97 d_aw98) r_awe9, TimeUnit u_Xw97) => u_Xw97 -> Sem r_awe9 ()
+ Polysemy.Time.Data.Time: sleep :: forall t d u r. TimeUnit u => Member (Time t d) r => u -> Sem r ()
- Polysemy.Time.Data.Time: today :: forall t_aw93 d_aw94 r_awe8. MemberWithError (Time t_aw93 d_aw94) r_awe8 => Sem r_awe8 d_aw94
+ Polysemy.Time.Data.Time: today :: forall t d r. Member (Time t d) r => Sem r d

Files

lib/Polysemy/Time.hs view
@@ -7,19 +7,30 @@   -- * Time effect   module Polysemy.Time.Data.Time,   GhcTime,+   -- * Interpreters   interpretTimeGhc,   interpretTimeGhcAt,   interpretTimeGhcConstant,   interpretTimeGhcConstantNow,+   -- * Data types   module Polysemy.Time.Data.TimeUnit,-  module Polysemy.Time.Calendar,+  Calendar (..),+  HasDay (..),+  HasHour (..),+  HasMinute (..),+  HasMonth (..),+  HasNanoSecond (..),+  HasSecond (..),+  HasYear (..),+   -- * Combinators   measure,   while,   loop,   loop_,+  diff, ) where  import Polysemy.Time.Calendar (@@ -47,6 +58,7 @@   Years (..),   convert,   )+import Polysemy.Time.Diff (diff) import Polysemy.Time.Ghc (   GhcTime,   interpretTimeGhc,
lib/Polysemy/Time/At.hs view
@@ -1,3 +1,4 @@+-- |Interceptors for fixing a specific time, Internal module Polysemy.Time.At where  import Polysemy (intercept)
lib/Polysemy/Time/Calendar.hs view
@@ -1,10 +1,13 @@+{-# options_haddock prune #-}++-- |Classes for constructing datetime values and extracting time components, Internal module Polysemy.Time.Calendar where  import Data.Time (   Day,   DiffTime,-  TimeOfDay(TimeOfDay),-  UTCTime(UTCTime),+  TimeOfDay (TimeOfDay),+  UTCTime (UTCTime),   fromGregorian,   timeOfDayToTime,   timeToTimeOfDay,
lib/Polysemy/Time/Class/Instant.hs view
@@ -1,7 +1,9 @@+-- |The 'Instant' class, Internal module Polysemy.Time.Class.Instant where  import Data.Time (Day, UTCTime(UTCTime)) +-- |This abstracts over types that refer to a specific point in time. class Instant i dt | i -> dt where   dateTime :: i -> dt 
lib/Polysemy/Time/Data/Time.hs view
@@ -1,5 +1,10 @@+{-# options_haddock prune #-}++-- |Time effect, Internal module Polysemy.Time.Data.Time where +import Polysemy (makeSem_)+ import Polysemy.Time.Data.TimeUnit (AddTimeUnit, TimeUnit)  -- |The Time effect.@@ -17,4 +22,46 @@   -- |Set the current date, if the interpreter supports it.   SetDate :: d -> Time t d m () -makeSem ''Time+makeSem_ ''Time++-- |Produce the current time, possibly relative to what was set with 'SetTime' or 'SetDate'+now ::+  ∀ t d r .+  Member (Time t d) r =>+  Sem r t++-- |Produce the current date, possibly relative to what was set with 'SetTime' or 'SetDate'+today ::+  ∀ t d r .+  Member (Time t d) r =>+  Sem r d++-- |Suspend the current computation for the specified time span.+sleep ::+  ∀ t d u r .+  TimeUnit u =>+  Member (Time t d) r =>+  u ->+  Sem r ()++-- |Set the current time, if the interpreter supports it.+setTime ::+  ∀ t d r .+  Member (Time t d) r =>+  t ->+  Sem r ()++-- |Adjust the current time relatively, if the interpreter supports it.+adjust ::+  ∀ t d u1 u2 r .+  AddTimeUnit t u1 u2 =>+  Member (Time t d) r =>+  u1 ->+  Sem r ()++-- |Set the current date, if the interpreter supports it.+setDate ::+  ∀ t d r .+  Member (Time t d) r =>+  d ->+  Sem r ()
lib/Polysemy/Time/Data/TimeUnit.hs view
@@ -1,3 +1,4 @@+-- |TimeUnit Class and Data Types, Internal module Polysemy.Time.Data.TimeUnit where  import Data.Time (@@ -8,6 +9,7 @@   ) import Torsor (Additive, Scaling, Torsor, add, scale) +-- |For deriving via. newtype FromSeconds a =   FromSeconds a   deriving (Eq, Show)@@ -36,16 +38,19 @@  -- * Data types used to specify time spans, e.g. for sleeping. +-- |Years. newtype Years =   Years { unYear :: Int64 }   deriving (Eq, Show, Generic)   deriving newtype (Num, Real, Enum, Integral, Ord, Additive) +-- |Months. newtype Months =   Months { unMonths :: Int64 }   deriving (Eq, Show, Generic)   deriving newtype (Num, Real, Enum, Integral, Ord, Additive) +-- |Weeks. newtype Weeks =   Weeks { unWeeks :: Int64 }   deriving (Eq, Show, Generic)@@ -55,6 +60,7 @@   nanos =     NanoSeconds 604800000000000 +-- |Days. newtype Days =   Days { unDays :: Int64 }   deriving (Eq, Show, Generic)@@ -64,6 +70,7 @@   nanos =     NanoSeconds 86400000000000 +-- |Hours. newtype Hours =   Hours { unHours :: Int64 }   deriving (Eq, Show, Generic)@@ -73,6 +80,7 @@   nanos =     NanoSeconds 3600000000000 +-- |Minutes. newtype Minutes =   Minutes { unMinutes :: Int64 }   deriving (Eq, Show, Generic)@@ -82,6 +90,7 @@   nanos =     NanoSeconds 60000000000 +-- |Seconds. newtype Seconds =   Seconds { unSeconds :: Int64 }   deriving (Eq, Show, Generic)@@ -91,6 +100,7 @@   nanos =     NanoSeconds 1000000000 +-- |Milliseconds. newtype MilliSeconds =   MilliSeconds { unMilliSeconds :: Int64 }   deriving (Eq, Show, Generic)@@ -101,6 +111,7 @@   nanos =     NanoSeconds 1000000 +-- |Microseconds. newtype MicroSeconds =   MicroSeconds { unMicroSeconds :: Int64 }   deriving (Eq, Show, Generic)@@ -111,6 +122,8 @@   nanos =     NanoSeconds 1000 +-- |Nanoseconds.+-- This is the base unit for all conversions. newtype NanoSeconds =   NanoSeconds { unNanoSeconds :: Int64 }   deriving (Eq, Show, Generic)@@ -160,9 +173,11 @@ convert =   fromNanos . toNanos +-- |Convenience alias for 'addTimeUnit'. type AddTimeUnit t u1 u2 =   (TimeUnit u1, TimeUnit u2, Torsor t u2) +-- |Add a time unit to an instant. addTimeUnit ::   ∀ t u1 u2 .   AddTimeUnit t u1 u2 =>
lib/Polysemy/Time/Debug.hs view
@@ -1,10 +1,12 @@-{-# LANGUAGE NoImplicitPrelude #-}+{-# language NoImplicitPrelude #-}+{-# options_haddock prune, hide #-} +-- |Debug printing, Internal module Polysemy.Time.Debug where  import Data.String.Interpolate (i) import qualified Data.Text as Text-import GHC.Stack (SrcLoc(..))+import GHC.Stack (SrcLoc (..)) import Relude import System.IO.Unsafe (unsafePerformIO) 
lib/Polysemy/Time/Diff.hs view
@@ -1,3 +1,4 @@+-- |Diff Combinator, Internal module Polysemy.Time.Diff where  import Torsor (Torsor, difference)@@ -5,6 +6,7 @@ import Polysemy.Time.Class.Instant (Instant, dateTime) import Polysemy.Time.Data.TimeUnit (TimeUnit, convert) +-- |Subtract two arbitrary values that can be converted to an 'Instant'. diff ::   ∀ dt u i1 i2 .   TimeUnit u =>
lib/Polysemy/Time/Ghc.hs view
@@ -1,3 +1,6 @@+{-# options_haddock prune #-}++-- |'Time' interpreters for the data types from "Data.Time", Internal module Polysemy.Time.Ghc where  import Control.Concurrent (threadDelay)
lib/Polysemy/Time/Loop.hs view
@@ -1,8 +1,9 @@+-- |Combinators for looping with a sleep interval, Internal module Polysemy.Time.Loop where +import qualified Polysemy.Time.Data.Time as Time import Polysemy.Time.Data.Time (Time) import Polysemy.Time.Data.TimeUnit (TimeUnit)-import qualified Polysemy.Time.Data.Time as Time  -- |Repeatedly run the @action@, sleeping for @interval@ between executions. -- Stops when @action@ returns @False@.
lib/Polysemy/Time/Measure.hs view
@@ -1,3 +1,4 @@+-- |Measure an Action's Duration, Internal module Polysemy.Time.Measure where  import Torsor (Torsor)
lib/Polysemy/Time/Orphans.hs view
@@ -1,9 +1,11 @@-{-# OPTIONS_GHC -fno-warn-orphans #-}+{-# options_ghc -fno-warn-orphans #-}+{-# options_haddock prune, hide #-} +-- |Orphans for "Data.Time", Internal module Polysemy.Time.Orphans where -import Data.Time (diffUTCTime, addUTCTime, NominalDiffTime, UTCTime)-import Torsor (Additive(..), Torsor(..))+import Data.Time (NominalDiffTime, UTCTime, addUTCTime, diffUTCTime)+import Torsor (Additive (..), Torsor (..))  instance Additive NominalDiffTime where   zero =
lib/Polysemy/Time/Prelude.hs view
@@ -1,6 +1,7 @@-{-# options_haddock hide #-}-{-# LANGUAGE NoImplicitPrelude #-}+{-# language NoImplicitPrelude #-}+{-# options_haddock prune, hide #-} +-- |Prelude, Internal module Polysemy.Time.Prelude (   module Polysemy.Time.Prelude,   module Data.Foldable,
lib/Polysemy/Time/Sleep.hs view
@@ -1,8 +1,11 @@+{-# options_haddock prune, hide #-}++-- |Helpers for sleeping, Internal module Polysemy.Time.Sleep where  import Control.Concurrent (threadDelay) -import Polysemy.Time.Data.TimeUnit (MicroSeconds(MicroSeconds), TimeUnit, convert)+import Polysemy.Time.Data.TimeUnit (MicroSeconds (MicroSeconds), TimeUnit, convert)  uSleep ::   Member (Embed IO) r =>
lib/Prelude.hs view
@@ -1,3 +1,6 @@+{-# options_haddock prune, hide #-}++-- |Prelude, Internal module Prelude (   module Polysemy.Time.Prelude, ) where
polysemy-time.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           polysemy-time-version:        0.2.0.1+version:        0.2.0.2 synopsis:       Polysemy Effect for Time description:    Please see the readme on Github at <https://github.com/tek/polysemy-time> category:       Time@@ -104,7 +104,7 @@   build-depends:       aeson >=1.4     , base ==4.*-    , polysemy >=1.3+    , polysemy >=1.4     , relude >=0.7     , string-interpolate >=0.2     , template-haskell