-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A tiny compile-time time utility library inspired by zeit/ms
--   
--   A tiny compile-time time utility library inspired by zeit/ms
@package duration
@version 0.1.0.0


-- | This module exports internally used type classes and data types. You
--   can extend this package's functionality by utilizing them.
module Data.Time.Clock.Duration.Types

-- | The <a>AbsoluteDuration</a> class provides how to convert the given
--   <a>Time</a> into a specific unit of time. An instance should represent
--   a quantity with <a>the dimension of T</a>.
--   
--   42 seconds in <a>DiffTime</a> (seconds):
--   
--   <pre>
--   &gt;&gt;&gt; [t| 42s |] :: DiffTime
--   42s
--   </pre>
--   
--   42 seconds in <a>CUSeconds</a> (microseconds):
--   
--   <pre>
--   &gt;&gt;&gt; [t| 42s |] :: CUSeconds
--   42000000
--   </pre>
class AbsoluteDuration a
toAbsoluteDuration :: AbsoluteDuration a => Time -> a

-- | The <a>RelativeDuration</a> class represents how to calculate how long
--   the given <a>Time</a> is when measured in a specific unit of time. An
--   instance should represent a quantity with <a>the dimension of 1</a>.
--   
--   42 minutes in seconds:
--   
--   <pre>
--   &gt;&gt;&gt; [s| 42m |] :: Int
--   2520
--   </pre>
--   
--   3 seconds in microseconds:
--   
--   <pre>
--   &gt;&gt;&gt; [µs| 3s |] :: Int
--   3000000
--   </pre>
class RelativeDuration a
toRelativeDuration :: (RelativeDuration a, HasResolution r) => Proxy r -> Time -> a

-- | The parsing result of a string inside a quasiquoter.
data Time
Picosec :: Rational -> Time
Nanosec :: Rational -> Time
Microsec :: Rational -> Time

-- | Denoted by <tt>ms</tt>, <tt>msec</tt>, <tt>msecs</tt>,
--   <tt>millisecond</tt>, or <tt>milliseconds</tt>
Millisec :: Rational -> Time

-- | Denoted by <tt>s</tt>, <tt>sec</tt>, <tt>secs</tt>, <tt>second</tt>,
--   or <tt>seconds</tt>
Second :: Rational -> Time

-- | Denoted by <tt>m</tt>, <tt>min</tt>, <tt>mins</tt>, <tt>minute</tt>,
--   or <tt>minutes</tt>
Minute :: Rational -> Time

-- | Denoted by <tt>h</tt>, <tt>hr</tt>, <tt>hrs</tt>, <tt>hour</tt>, or
--   <tt>hours</tt>
Hour :: Rational -> Time

-- | Denoted by <tt>d</tt>, <tt>day</tt>, or <tt>days</tt>
Day :: Rational -> Time

-- | Denoted by <tt>w</tt>, <tt>week</tt>, or <tt>weeks</tt>
Week :: Rational -> Time

-- | Denoted by <tt>y</tt>, <tt>yr</tt>, <tt>yrs</tt>, <tt>year</tt>, or
--   <tt>years</tt>
Year :: Rational -> Time
instance Language.Haskell.TH.Syntax.Lift Data.Time.Clock.Duration.Types.Time
instance Data.Time.Clock.Duration.Types.AbsoluteDuration Data.Time.Clock.Internal.DiffTime.DiffTime
instance Data.Time.Clock.Duration.Types.AbsoluteDuration Data.Time.Clock.Internal.NominalDiffTime.NominalDiffTime
instance Data.Time.Clock.Duration.Types.AbsoluteDuration Foreign.C.Types.CUSeconds
instance Data.Time.Clock.Duration.Types.AbsoluteDuration Foreign.C.Types.CSUSeconds
instance Data.Time.Clock.Duration.Types.RelativeDuration GHC.Types.Int
instance Data.Time.Clock.Duration.Types.RelativeDuration GHC.Int.Int8
instance Data.Time.Clock.Duration.Types.RelativeDuration GHC.Int.Int16
instance Data.Time.Clock.Duration.Types.RelativeDuration GHC.Int.Int32
instance Data.Time.Clock.Duration.Types.RelativeDuration GHC.Int.Int64
instance Data.Time.Clock.Duration.Types.RelativeDuration GHC.Integer.Type.Integer
instance Data.Fixed.HasResolution a => Data.Time.Clock.Duration.Types.RelativeDuration (Data.Fixed.Fixed a)
instance GHC.Real.Integral a => Data.Time.Clock.Duration.Types.RelativeDuration (GHC.Real.Ratio a)
instance Data.Time.Clock.Duration.Types.RelativeDuration GHC.Types.Float
instance Data.Time.Clock.Duration.Types.RelativeDuration GHC.Types.Double


-- | All quasiquoters defined in this module are re-exported from
--   <tt>Data.Time.Clock.Duration</tt>.
module Data.Time.Clock.Duration.QQ

-- | A quasiquoter to denote a duration.
--   
--   <pre>
--   &gt;&gt;&gt; [t| 42s |] :: DiffTime
--   42s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1day |] :: DiffTime
--   86400s
--   </pre>
--   
--   The expression has the type of <tt><a>AbsoluteDuration</a> a =&gt;
--   a</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1ms |] :: NominalDiffTime
--   0.001s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1ms |] :: CSUSeconds
--   1000
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1ms |] :: CUSeconds
--   1000
--   </pre>
--   
--   You can use various expressions inside the quasiquoter. (See
--   <a>Time</a> for details.)
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1ms |] :: DiffTime
--   0.001s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1s |] :: DiffTime
--   1s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1m |] :: DiffTime
--   60s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1h |] :: DiffTime
--   3600s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1d |] :: DiffTime
--   86400s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1w |] :: DiffTime
--   604800s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1y |] :: DiffTime
--   31536000s
--   </pre>
t :: QuasiQuoter

-- | A quasiquoter to denote a duration in seconds. Its behavior varies
--   according to what you give to the quasiquoter.
--   
--   When a unitless number (like <tt>42</tt>) is supplied to <a>s</a>, the
--   expression has the type of <tt><a>AbsoluteDuration</a> a =&gt; a</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; [s| 42 |] :: DiffTime
--   42s
--   </pre>
--   
--   When you pass a string with a number and a valid unit (like
--   <tt>42s</tt>), the expression has the type of
--   <tt><a>RelativeDuration</a> a =&gt; a</tt>, and it represents how long
--   the given duration is in seconds.
--   
--   For example, how long is 42 minutes in seconds?
--   
--   <pre>
--   &gt;&gt;&gt; [s| 42m |] :: Int
--   2520
--   </pre>
--   
--   Note that short durations can be rounded to zero when treated as an
--   integer.
--   
--   <pre>
--   &gt;&gt;&gt; [s| 1ms |] :: Int
--   0
--   
--   &gt;&gt;&gt; [s| 1ms |] :: Integer
--   0
--   </pre>
--   
--   To avoid this, use <a>Ratio</a> or <a>Float</a> instead.
--   
--   <pre>
--   &gt;&gt;&gt; [s| 1ms |] :: Rational
--   1 % 1000
--   
--   &gt;&gt;&gt; [s| 1ms |] :: Float
--   1.0e-3
--   </pre>
s :: QuasiQuoter

-- | A quasiquoter to denote a duration in milliseconds. See <a>s</a> for
--   detailed usage.
--   
--   <pre>
--   &gt;&gt;&gt; [ms| 42 |] :: DiffTime
--   0.042s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [ms| 42s |] :: Integer
--   42000
--   </pre>
ms :: QuasiQuoter

-- | A quasiquoter to denote a duration in microseconds. See <a>s</a> for
--   detailed usage.
--   
--   <pre>
--   &gt;&gt;&gt; [µs| 42 |] :: DiffTime
--   0.000042s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [µs| 42s |] :: Integer
--   42000000
--   </pre>
µs :: QuasiQuoter

-- | A quasiquoter to denote a duration in nanoseconds. See <a>s</a> for
--   detailed usage.
--   
--   <pre>
--   &gt;&gt;&gt; [ns| 42 |] :: DiffTime
--   0.000000042s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [ns| 42s |] :: Integer
--   42000000000
--   </pre>
ns :: QuasiQuoter

-- | A quasiquoter to denote a duration in picoseconds. See <a>s</a> for
--   detailed usage.
--   
--   <pre>
--   &gt;&gt;&gt; [ps| 42 |] :: DiffTime
--   0.000000000042s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [ps| 42s |] :: Integer
--   42000000000000
--   </pre>
ps :: QuasiQuoter


-- | A tiny compile-time time utility library, inspired by <a>zeit/ms</a>.
module Data.Time.Clock.Duration

-- | A quasiquoter to denote a duration.
--   
--   <pre>
--   &gt;&gt;&gt; [t| 42s |] :: DiffTime
--   42s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1day |] :: DiffTime
--   86400s
--   </pre>
--   
--   The expression has the type of <tt><a>AbsoluteDuration</a> a =&gt;
--   a</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1ms |] :: NominalDiffTime
--   0.001s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1ms |] :: CSUSeconds
--   1000
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1ms |] :: CUSeconds
--   1000
--   </pre>
--   
--   You can use various expressions inside the quasiquoter. (See
--   <a>Time</a> for details.)
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1ms |] :: DiffTime
--   0.001s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1s |] :: DiffTime
--   1s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1m |] :: DiffTime
--   60s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1h |] :: DiffTime
--   3600s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1d |] :: DiffTime
--   86400s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1w |] :: DiffTime
--   604800s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [t| 1y |] :: DiffTime
--   31536000s
--   </pre>
t :: QuasiQuoter

-- | A quasiquoter to denote a duration in seconds. Its behavior varies
--   according to what you give to the quasiquoter.
--   
--   When a unitless number (like <tt>42</tt>) is supplied to <a>s</a>, the
--   expression has the type of <tt><a>AbsoluteDuration</a> a =&gt; a</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; [s| 42 |] :: DiffTime
--   42s
--   </pre>
--   
--   When you pass a string with a number and a valid unit (like
--   <tt>42s</tt>), the expression has the type of
--   <tt><a>RelativeDuration</a> a =&gt; a</tt>, and it represents how long
--   the given duration is in seconds.
--   
--   For example, how long is 42 minutes in seconds?
--   
--   <pre>
--   &gt;&gt;&gt; [s| 42m |] :: Int
--   2520
--   </pre>
--   
--   Note that short durations can be rounded to zero when treated as an
--   integer.
--   
--   <pre>
--   &gt;&gt;&gt; [s| 1ms |] :: Int
--   0
--   
--   &gt;&gt;&gt; [s| 1ms |] :: Integer
--   0
--   </pre>
--   
--   To avoid this, use <a>Ratio</a> or <a>Float</a> instead.
--   
--   <pre>
--   &gt;&gt;&gt; [s| 1ms |] :: Rational
--   1 % 1000
--   
--   &gt;&gt;&gt; [s| 1ms |] :: Float
--   1.0e-3
--   </pre>
s :: QuasiQuoter

-- | A quasiquoter to denote a duration in milliseconds. See <a>s</a> for
--   detailed usage.
--   
--   <pre>
--   &gt;&gt;&gt; [ms| 42 |] :: DiffTime
--   0.042s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [ms| 42s |] :: Integer
--   42000
--   </pre>
ms :: QuasiQuoter

-- | A quasiquoter to denote a duration in microseconds. See <a>s</a> for
--   detailed usage.
--   
--   <pre>
--   &gt;&gt;&gt; [µs| 42 |] :: DiffTime
--   0.000042s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [µs| 42s |] :: Integer
--   42000000
--   </pre>
µs :: QuasiQuoter

-- | A quasiquoter to denote a duration in nanoseconds. See <a>s</a> for
--   detailed usage.
--   
--   <pre>
--   &gt;&gt;&gt; [ns| 42 |] :: DiffTime
--   0.000000042s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [ns| 42s |] :: Integer
--   42000000000
--   </pre>
ns :: QuasiQuoter

-- | A quasiquoter to denote a duration in picoseconds. See <a>s</a> for
--   detailed usage.
--   
--   <pre>
--   &gt;&gt;&gt; [ps| 42 |] :: DiffTime
--   0.000000000042s
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [ps| 42s |] :: Integer
--   42000000000000
--   </pre>
ps :: QuasiQuoter
