time-units-types 0.1.0.0 → 0.2.0.0
raw patch · 3 files changed
+60/−66 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Data.Time.TypeLevel: data Attosecond (n :: Nat)
- Data.Time.TypeLevel: data Day (n :: Nat)
- Data.Time.TypeLevel: data Femtosecond (n :: Nat)
- Data.Time.TypeLevel: data Fortnight (n :: Nat)
- Data.Time.TypeLevel: data Hour (n :: Nat)
- Data.Time.TypeLevel: data Microsecond (n :: Nat)
- Data.Time.TypeLevel: data Millisecond (n :: Nat)
- Data.Time.TypeLevel: data Minute (n :: Nat)
- Data.Time.TypeLevel: data Nanosecond (n :: Nat)
- Data.Time.TypeLevel: data Picosecond (n :: Nat)
- Data.Time.TypeLevel: data Second (n :: Nat)
- Data.Time.TypeLevel: data Week (n :: Nat)
- Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration (Data.Time.TypeLevel.Attosecond n)
- Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration (Data.Time.TypeLevel.Day n)
- Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration (Data.Time.TypeLevel.Femtosecond n)
- Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration (Data.Time.TypeLevel.Fortnight n)
- Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration (Data.Time.TypeLevel.Hour n)
- Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration (Data.Time.TypeLevel.Microsecond n)
- Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration (Data.Time.TypeLevel.Millisecond n)
- Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration (Data.Time.TypeLevel.Minute n)
- Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration (Data.Time.TypeLevel.Nanosecond n)
- Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration (Data.Time.TypeLevel.Picosecond n)
- Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration (Data.Time.TypeLevel.Second n)
- Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration (Data.Time.TypeLevel.Week n)
+ Data.Time.TypeLevel: [Attosecond] :: Nat -> TimePeriod
+ Data.Time.TypeLevel: [Day] :: Nat -> TimePeriod
+ Data.Time.TypeLevel: [Femtosecond] :: Nat -> TimePeriod
+ Data.Time.TypeLevel: [Fortnight] :: Nat -> TimePeriod
+ Data.Time.TypeLevel: [Hour] :: Nat -> TimePeriod
+ Data.Time.TypeLevel: [Microsecond] :: Nat -> TimePeriod
+ Data.Time.TypeLevel: [Millisecond] :: Nat -> TimePeriod
+ Data.Time.TypeLevel: [Minute] :: Nat -> TimePeriod
+ Data.Time.TypeLevel: [Nanosecond] :: Nat -> TimePeriod
+ Data.Time.TypeLevel: [Picosecond] :: Nat -> TimePeriod
+ Data.Time.TypeLevel: [Second] :: Nat -> TimePeriod
+ Data.Time.TypeLevel: [Week] :: Nat -> TimePeriod
+ Data.Time.TypeLevel: data TimePeriod
+ Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration ('Data.Time.TypeLevel.Attosecond n)
+ Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration ('Data.Time.TypeLevel.Day n)
+ Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration ('Data.Time.TypeLevel.Femtosecond n)
+ Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration ('Data.Time.TypeLevel.Fortnight n)
+ Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration ('Data.Time.TypeLevel.Hour n)
+ Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration ('Data.Time.TypeLevel.Microsecond n)
+ Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration ('Data.Time.TypeLevel.Millisecond n)
+ Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration ('Data.Time.TypeLevel.Minute n)
+ Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration ('Data.Time.TypeLevel.Nanosecond n)
+ Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration ('Data.Time.TypeLevel.Picosecond n)
+ Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration ('Data.Time.TypeLevel.Second n)
+ Data.Time.TypeLevel: instance GHC.TypeNats.KnownNat n => Data.Time.TypeLevel.KnownDuration ('Data.Time.TypeLevel.Week n)
Files
- README.md +5/−1
- src/Data/Time/TypeLevel.hs +54/−63
- time-units-types.cabal +1/−2
README.md view
@@ -1,5 +1,9 @@ # time-units-types +++[](https://hackage.haskell.org/package/time-units-types)+ This Haskell library exports types which can be used to describe simple type periods at the type-level. The type-level descriptions can then be reifed to corresponding values of the [`time-units`](https://hackage.haskell.org/package/time-units) library. ```haskell@@ -7,7 +11,7 @@ import Data.Time.TypeLevel -type TenSeconds = Second 10+type TenSeconds = 'Second 10 main :: IO () main = do
src/Data/Time/TypeLevel.hs view
@@ -5,6 +5,7 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE GADTSyntax #-} -- | Exports types which can be used to describe time periods at -- the type-level. Use the `durationVal` function to reify them as the@@ -14,65 +15,55 @@ KnownDuration(..), durationMicroseconds, - Attosecond,- Femtosecond,- Picosecond,- Nanosecond,- Microsecond,- Millisecond,- Second,- Minute,- Hour,- Day,- Week,- Fortnight+ TimePeriod(..) ) where ------------------------------------------------------------------------------- import GHC.TypeLits -import Data.Time.Units qualified as Units+import qualified Data.Time.Units as Units import Data.Proxy import Data.Kind ------------------------------------------------------------------------------- --- | Represents @n@-many attoseconds.-data Attosecond (n :: Nat)+data TimePeriod where+ -- | Represents @n@-many attoseconds.+ Attosecond :: Nat -> TimePeriod --- | Represents @n@-many femtoseconds.-data Femtosecond (n :: Nat)+ -- | Represents @n@-many femtoseconds.+ Femtosecond :: Nat -> TimePeriod --- | Represents @n@-many picoseconds.-data Picosecond (n :: Nat)+ -- | Represents @n@-many picoseconds.+ Picosecond :: Nat -> TimePeriod --- | Represents @n@-many nanoseconds.-data Nanosecond (n :: Nat)+ -- | Represents @n@-many nanoseconds.+ Nanosecond :: Nat -> TimePeriod --- | Represents @n@-many microseconds.-data Microsecond (n :: Nat)+ -- | Represents @n@-many microseconds.+ Microsecond :: Nat -> TimePeriod --- | Represents @n@-many milliseconds.-data Millisecond (n :: Nat)+ -- | Represents @n@-many milliseconds.+ Millisecond :: Nat -> TimePeriod --- | Represents @n@-many seconds.-data Second (n :: Nat)+ -- | Represents @n@-many seconds.+ Second :: Nat -> TimePeriod --- | Represents @n@-many minutes.-data Minute (n :: Nat)+ -- | Represents @n@-many minutes.+ Minute :: Nat -> TimePeriod --- | Represents @n@-many hours.-data Hour (n :: Nat)+ -- | Represents @n@-many hours.+ Hour :: Nat -> TimePeriod --- | Represents @n@-many days.-data Day (n :: Nat)+ -- | Represents @n@-many days.+ Day :: Nat -> TimePeriod --- | Represents @n@-many weeks.-data Week (n :: Nat)+ -- | Represents @n@-many weeks.+ Week :: Nat -> TimePeriod --- | Represents @n@-many fortnights.-data Fortnight (n :: Nat)+ -- | Represents @n@-many fortnights.+ Fortnight :: Nat -> TimePeriod -- | A class of types which can be reified as value-level descriptions of -- time periods.@@ -84,12 +75,12 @@ -- | `durationVal` reifies the duration as the corresponding value-level -- type. Intended to be used with @TypeApplications@. --- -- >>> durationVal @(Second 10)+ -- >>> durationVal @('Second 10) -- 10s :: Data.Time.Units.Second durationVal :: DurationUnit k -instance KnownNat n => KnownDuration (Attosecond n) where- type DurationUnit (Attosecond n) = Units.Attosecond+instance KnownNat n => KnownDuration ('Attosecond n) where+ type DurationUnit ('Attosecond n) = Units.Attosecond durationVal = fromInteger @Units.Attosecond $@@ -99,85 +90,85 @@ -- type-level duration as microseconds on the value level. Intended to be -- used with @TypeApplications@. ----- >>> durationMicroseconds @(Second 10)+-- >>> durationMicroseconds @('Second 10) -- 10000000 :: Integer durationMicroseconds :: forall d . (KnownDuration d, Units.TimeUnit (DurationUnit d)) => Integer durationMicroseconds = Units.toMicroseconds $ durationVal @d -instance KnownNat n => KnownDuration (Femtosecond n) where- type DurationUnit (Femtosecond n) = Units.Femtosecond+instance KnownNat n => KnownDuration ('Femtosecond n) where+ type DurationUnit ('Femtosecond n) = Units.Femtosecond durationVal = fromInteger @Units.Femtosecond $ natVal (Proxy :: Proxy n) -instance KnownNat n => KnownDuration (Picosecond n) where- type DurationUnit (Picosecond n) = Units.Picosecond+instance KnownNat n => KnownDuration ('Picosecond n) where+ type DurationUnit ('Picosecond n) = Units.Picosecond durationVal = fromInteger @Units.Picosecond $ natVal (Proxy :: Proxy n) -instance KnownNat n => KnownDuration (Nanosecond n) where- type DurationUnit (Nanosecond n) = Units.Nanosecond+instance KnownNat n => KnownDuration ('Nanosecond n) where+ type DurationUnit ('Nanosecond n) = Units.Nanosecond durationVal = fromInteger @Units.Nanosecond $ natVal (Proxy :: Proxy n) -instance KnownNat n => KnownDuration (Microsecond n) where- type DurationUnit (Microsecond n) = Units.Microsecond+instance KnownNat n => KnownDuration ('Microsecond n) where+ type DurationUnit ('Microsecond n) = Units.Microsecond durationVal = fromInteger @Units.Microsecond $ natVal (Proxy :: Proxy n) -instance KnownNat n => KnownDuration (Millisecond n) where- type DurationUnit (Millisecond n) = Units.Millisecond+instance KnownNat n => KnownDuration ('Millisecond n) where+ type DurationUnit ('Millisecond n) = Units.Millisecond durationVal = fromInteger @Units.Millisecond $ natVal (Proxy :: Proxy n) -instance KnownNat n => KnownDuration (Second n) where- type DurationUnit (Second n) = Units.Second+instance KnownNat n => KnownDuration ('Second n) where+ type DurationUnit ('Second n) = Units.Second durationVal = fromInteger @Units.Second $ natVal (Proxy :: Proxy n) -instance KnownNat n => KnownDuration (Minute n) where- type DurationUnit (Minute n) = Units.Minute+instance KnownNat n => KnownDuration ('Minute n) where+ type DurationUnit ('Minute n) = Units.Minute durationVal = fromInteger @Units.Minute $ natVal (Proxy :: Proxy n) -instance KnownNat n => KnownDuration (Hour n) where- type DurationUnit (Hour n) = Units.Hour+instance KnownNat n => KnownDuration ('Hour n) where+ type DurationUnit ('Hour n) = Units.Hour durationVal = fromInteger @Units.Hour $ natVal (Proxy :: Proxy n) -instance KnownNat n => KnownDuration (Day n) where- type DurationUnit (Day n) = Units.Day+instance KnownNat n => KnownDuration ('Day n) where+ type DurationUnit ('Day n) = Units.Day durationVal = fromInteger @Units.Day $ natVal (Proxy :: Proxy n) -instance KnownNat n => KnownDuration (Week n) where- type DurationUnit (Week n) = Units.Week+instance KnownNat n => KnownDuration ('Week n) where+ type DurationUnit ('Week n) = Units.Week durationVal = fromInteger @Units.Week $ natVal (Proxy :: Proxy n) -instance KnownNat n => KnownDuration (Fortnight n) where- type DurationUnit (Fortnight n) = Units.Fortnight+instance KnownNat n => KnownDuration ('Fortnight n) where+ type DurationUnit ('Fortnight n) = Units.Fortnight durationVal = fromInteger @Units.Fortnight $
time-units-types.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: time-units-types-version: 0.1.0.0+version: 0.2.0.0 synopsis: Type-level representations of time durations. description: Please see the README on GitHub at <https://github.com/mbg/time-units-types#readme> category: Data@@ -36,7 +36,6 @@ DataKinds FlexibleInstances FunctionalDependencies- ImportQualifiedPost KindSignatures MultiParamTypeClasses PolyKinds