Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
TimeUnit Class and Data Types, Internal
Synopsis
- newtype FromSeconds a = FromSeconds a
- class TimeUnit u where
- nanos :: NanoSeconds
- toNanos :: u -> NanoSeconds
- fromNanos :: NanoSeconds -> u
- newtype Years = Years {}
- newtype Months = Months {}
- newtype Weeks = Weeks {}
- newtype Days = Days {}
- newtype Hours = Hours {}
- newtype Minutes = Minutes {}
- newtype Seconds = Seconds {}
- newtype MilliSeconds = MilliSeconds {}
- newtype MicroSeconds = MicroSeconds {}
- newtype NanoSeconds = NanoSeconds {}
- safeDiv :: Real a => Integral a => a -> a -> Maybe a
- divOr0 :: Real a => Integral a => a -> a -> a
- convert :: TimeUnit a => TimeUnit b => a -> b
- type AddTimeUnit t u1 u2 = (TimeUnit u1, TimeUnit u2, Torsor t u2)
- addTimeUnit :: forall t u1 u2. AddTimeUnit t u1 u2 => u1 -> t -> t
- secondsFrac :: TimeUnit u => u -> Double
Documentation
newtype FromSeconds a Source #
For deriving via.
Instances
class TimeUnit u where Source #
Types that represent an amount of time that can be converted to each other.
The methods are internal, the API function is convert
.
nanos :: NanoSeconds Source #
toNanos :: u -> NanoSeconds Source #
default toNanos :: Integral u => u -> NanoSeconds Source #
fromNanos :: NanoSeconds -> u Source #
default fromNanos :: Integral u => NanoSeconds -> u Source #
Instances
Data types used to specify time spans, e.g. for sleeping.
Years.
Instances
FromJSON Years Source # | |
ToJSON Years Source # | |
Defined in Polysemy.Time.Data.TimeUnit | |
Enum Years Source # | |
Defined in Polysemy.Time.Data.TimeUnit | |
Generic Years Source # | |
Num Years Source # | |
Integral Years Source # | |
Real Years Source # | |
Defined in Polysemy.Time.Data.TimeUnit toRational :: Years -> Rational # | |
Show Years Source # | |
Eq Years Source # | |
Ord Years Source # | |
Additive Years Source # | |
type Rep Years Source # | |
Defined in Polysemy.Time.Data.TimeUnit |
Months.
Instances
FromJSON Months Source # | |
ToJSON Months Source # | |
Defined in Polysemy.Time.Data.TimeUnit | |
Enum Months Source # | |
Defined in Polysemy.Time.Data.TimeUnit | |
Generic Months Source # | |
Num Months Source # | |
Integral Months Source # | |
Defined in Polysemy.Time.Data.TimeUnit | |
Real Months Source # | |
Defined in Polysemy.Time.Data.TimeUnit toRational :: Months -> Rational # | |
Show Months Source # | |
Eq Months Source # | |
Ord Months Source # | |
Additive Months Source # | |
type Rep Months Source # | |
Defined in Polysemy.Time.Data.TimeUnit |
Weeks.
Instances
FromJSON Weeks Source # | |
ToJSON Weeks Source # | |
Defined in Polysemy.Time.Data.TimeUnit | |
Enum Weeks Source # | |
Defined in Polysemy.Time.Data.TimeUnit | |
Generic Weeks Source # | |
Num Weeks Source # | |
Integral Weeks Source # | |
Real Weeks Source # | |
Defined in Polysemy.Time.Data.TimeUnit toRational :: Weeks -> Rational # | |
Show Weeks Source # | |
Eq Weeks Source # | |
Ord Weeks Source # | |
TimeUnit Weeks Source # | |
Defined in Polysemy.Time.Data.TimeUnit nanos :: NanoSeconds Source # toNanos :: Weeks -> NanoSeconds Source # fromNanos :: NanoSeconds -> Weeks Source # | |
Additive Weeks Source # | |
type Rep Weeks Source # | |
Defined in Polysemy.Time.Data.TimeUnit |
Days.
Instances
FromJSON Days Source # | |
ToJSON Days Source # | |
Defined in Polysemy.Time.Data.TimeUnit | |
Enum Days Source # | |
Generic Days Source # | |
Num Days Source # | |
Integral Days Source # | |
Real Days Source # | |
Defined in Polysemy.Time.Data.TimeUnit toRational :: Days -> Rational # | |
Show Days Source # | |
Eq Days Source # | |
Ord Days Source # | |
TimeUnit Days Source # | |
Defined in Polysemy.Time.Data.TimeUnit nanos :: NanoSeconds Source # toNanos :: Days -> NanoSeconds Source # fromNanos :: NanoSeconds -> Days Source # | |
Additive Days Source # | |
type Rep Days Source # | |
Defined in Polysemy.Time.Data.TimeUnit |
Hours.
Instances
FromJSON Hours Source # | |
ToJSON Hours Source # | |
Defined in Polysemy.Time.Data.TimeUnit | |
Enum Hours Source # | |
Defined in Polysemy.Time.Data.TimeUnit | |
Generic Hours Source # | |
Num Hours Source # | |
Integral Hours Source # | |
Real Hours Source # | |
Defined in Polysemy.Time.Data.TimeUnit toRational :: Hours -> Rational # | |
Show Hours Source # | |
Eq Hours Source # | |
Ord Hours Source # | |
TimeUnit Hours Source # | |
Defined in Polysemy.Time.Data.TimeUnit nanos :: NanoSeconds Source # toNanos :: Hours -> NanoSeconds Source # fromNanos :: NanoSeconds -> Hours Source # | |
Additive Hours Source # | |
type Rep Hours Source # | |
Defined in Polysemy.Time.Data.TimeUnit |
Minutes.
Instances
FromJSON Minutes Source # | |
ToJSON Minutes Source # | |
Defined in Polysemy.Time.Data.TimeUnit | |
Enum Minutes Source # | |
Generic Minutes Source # | |
Num Minutes Source # | |
Integral Minutes Source # | |
Defined in Polysemy.Time.Data.TimeUnit | |
Real Minutes Source # | |
Defined in Polysemy.Time.Data.TimeUnit toRational :: Minutes -> Rational # | |
Show Minutes Source # | |
Eq Minutes Source # | |
Ord Minutes Source # | |
Defined in Polysemy.Time.Data.TimeUnit | |
TimeUnit Minutes Source # | |
Defined in Polysemy.Time.Data.TimeUnit nanos :: NanoSeconds Source # toNanos :: Minutes -> NanoSeconds Source # fromNanos :: NanoSeconds -> Minutes Source # | |
Additive Minutes Source # | |
type Rep Minutes Source # | |
Defined in Polysemy.Time.Data.TimeUnit |
Seconds.
Instances
FromJSON Seconds Source # | |
ToJSON Seconds Source # | |
Defined in Polysemy.Time.Data.TimeUnit | |
Enum Seconds Source # | |
Generic Seconds Source # | |
Num Seconds Source # | |
Integral Seconds Source # | |
Defined in Polysemy.Time.Data.TimeUnit | |
Real Seconds Source # | |
Defined in Polysemy.Time.Data.TimeUnit toRational :: Seconds -> Rational # | |
Show Seconds Source # | |
Eq Seconds Source # | |
Ord Seconds Source # | |
Defined in Polysemy.Time.Data.TimeUnit | |
TimeUnit Seconds Source # | |
Defined in Polysemy.Time.Data.TimeUnit nanos :: NanoSeconds Source # toNanos :: Seconds -> NanoSeconds Source # fromNanos :: NanoSeconds -> Seconds Source # | |
Additive Seconds Source # | |
type Rep Seconds Source # | |
Defined in Polysemy.Time.Data.TimeUnit |
newtype MilliSeconds Source #
Milliseconds.
Instances
newtype MicroSeconds Source #
Microseconds.
Instances
newtype NanoSeconds Source #
Nanoseconds. This is the base unit for all conversions.
Instances
convert :: TimeUnit a => TimeUnit b => a -> b Source #
Convert between different time spans.
>>>
convert (picosecondsToDiffTime 50000000) :: MicroSeconds
MicroSeconds {unMicroSeconds = 50}
>>>
convert (MilliSeconds 5) :: MicroSeconds
MicroSeconds 5000
type AddTimeUnit t u1 u2 = (TimeUnit u1, TimeUnit u2, Torsor t u2) Source #
Convenience alias for addTimeUnit
.
addTimeUnit :: forall t u1 u2. AddTimeUnit t u1 u2 => u1 -> t -> t Source #
Add a time unit to an instant.
secondsFrac :: TimeUnit u => u -> Double Source #
Convert a unit into a number of seconds, keeping the subsecond part as fractional digits.