packages feed

time-domain 0.1.0.0 → 0.1.0.1

raw patch · 2 files changed

+37/−7 lines, 2 filesdep ~basePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: base

API changes (from Hackage documentation)

- Data.TimeDomain: instance Data.TimeDomain.TimeDifference GHC.Integer.Type.Integer
- Data.TimeDomain: instance Data.TimeDomain.TimeDomain GHC.Integer.Type.Integer
- Data.TimeDomain: type family Diff time;
+ Data.TimeDomain: add :: TimeDifference d => d -> d -> d
+ Data.TimeDomain: addTime :: TimeDomain time => time -> Diff time -> time
+ Data.TimeDomain: instance Data.TimeDomain.TimeDifference GHC.Num.Integer.Integer
+ Data.TimeDomain: instance Data.TimeDomain.TimeDomain GHC.Num.Integer.Integer
+ Data.TimeDomain: type Diff time;

Files

src/Data/TimeDomain.hs view
@@ -17,15 +17,17 @@   where  -- time-import Data.Time.Clock (UTCTime, diffUTCTime)+import Data.Time.Clock (UTCTime, diffUTCTime, addUTCTime)  {- | A time domain is an affine space representing a notion of time, such as real time, simulated time, steps, or a completely different notion. -Expected law:+Expected laws: -@(t1 `diffTime` t3) `difference` (t1 `diffTime` t2) = t2 `diffTime` t3@+* @(t1 `diffTime` t3) `difference` (t1 `diffTime` t2) = t2 `diffTime` t3@+* @(t `addTime` dt) `diffTime` t = dt@+* @(t `addTime` dt1) `addTime` dt2 = t `addTime` (dt1 `add` dt2)@ -} class TimeDifference (Diff time) => TimeDomain time where   -- | The type of differences or durations between two timestamps@@ -35,51 +37,70 @@    Mnemonic: 'diffTime' behaves like the '(-)' operator: -  @'diffTime' earlier later = later `'diffTime'` earlier@ is the duration it takes from @earlier@ to @later.+  @'diffTime' earlier later = later `'diffTime'` earlier@ is the duration it takes from @earlier@ to @later@.   -}   diffTime :: time -> time -> Diff time +  {- | Add a time difference to a timestamp.+  -}+  addTime :: time -> Diff time -> time+ {- | A type of durations, or differences betweens time stamps. -For the expected law, see 'TimeDomain'.+Expected laws:++* `add` is commutative and associative+* @(dt1 `difference` dt2) `add` dt2 = dt1@ -} class TimeDifference d where   -- | Calculate the difference between two durations,   --   compatibly with 'diffTime'.   difference :: d -> d -> d +  -- | Add two time differences.+  add :: d -> d -> d+ -- | Differences between 'UTCTime's are measured in seconds. instance TimeDomain UTCTime where   type Diff UTCTime = Double   diffTime t1 t2 = realToFrac $ diffUTCTime t1 t2+  addTime = flip $ addUTCTime . realToFrac  instance TimeDifference Double where   difference = (-)+  add = (+)  instance TimeDomain Double where   type Diff Double = Double   diffTime = (-)+  addTime = (+)  instance TimeDifference Float where   difference = (-)+  add = (+)  instance TimeDomain Float where   type Diff Float = Float   diffTime = (-)+  addTime = (+)  instance TimeDifference Integer where   difference = (-)+  add = (+)  instance TimeDomain Integer where   type Diff Integer = Integer   diffTime = (-)+  addTime = (+)  instance TimeDifference () where   difference _ _ = ()+  add _ _ = ()  instance TimeDomain () where   type Diff () = ()   diffTime _ _ = ()+  addTime _ _ = ()  -- | Any 'Num' can be wrapped to form a 'TimeDomain'. newtype NumTimeDomain a = NumTimeDomain { fromNumTimeDomain :: a }@@ -87,7 +108,9 @@  instance Num a => TimeDifference (NumTimeDomain a) where   difference = (-)+  add = (+)  instance Num a => TimeDomain (NumTimeDomain a) where   type Diff (NumTimeDomain a) = NumTimeDomain a   diffTime = (-)+  addTime = (+)
time-domain.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               time-domain-version:            0.1.0.0+version:            0.1.0.1 license:            MIT license-file:       LICENSE author:             Manuel Bärenz@@ -12,11 +12,18 @@ extra-source-files: CHANGELOG.md category:           FRP homepage:           https://github.com/turion/time-domain/+source-repository head+  type:     git+  location: git@github.com:turion/time-domain.git+source-repository this+  type:     git+  location: git@github.com:turion/time-domain.git+  tag:      v0.1.0.1  library   exposed-modules:  Data.TimeDomain   build-depends:-      base >= 4.13.0 && <= 4.17+      base >= 4.13.0 && <= 4.18     , time >= 1.9   hs-source-dirs:   src   default-language: Haskell2010