Copyright | (c) Ryota Kameoka 2018 |
---|---|

License | BSD-3 |

Maintainer | kameoka.ryota@gmail.com |

Stability | experimental |

Safe Haskell | None |

Language | Haskell2010 |

All quasiquoters defined in this module are re-exported from `Data.Time.Clock.Duration`

.

## Synopsis

- t :: QuasiQuoter
- s :: QuasiQuoter
- ms :: QuasiQuoter
- µs :: QuasiQuoter
- ns :: QuasiQuoter
- ps :: QuasiQuoter

# Quasiquoters

t :: QuasiQuoter Source #

A quasiquoter to denote a duration.

`>>>`

42s`[t| 42s |] :: DiffTime`

`>>>`

86400s`[t| 1day |] :: DiffTime`

The expression has the type of

.`AbsoluteDuration`

a => a

`>>>`

0.001s`[t| 1ms |] :: NominalDiffTime`

`>>>`

1000`[t| 1ms |] :: CSUSeconds`

`>>>`

1000`[t| 1ms |] :: CUSeconds`

You can use various expressions inside the quasiquoter. (See `Time`

for details.)

`>>>`

0.001s`[t| 1ms |] :: DiffTime`

`>>>`

1s`[t| 1s |] :: DiffTime`

`>>>`

60s`[t| 1m |] :: DiffTime`

`>>>`

3600s`[t| 1h |] :: DiffTime`

`>>>`

86400s`[t| 1d |] :: DiffTime`

`>>>`

604800s`[t| 1w |] :: DiffTime`

`>>>`

31536000s`[t| 1y |] :: DiffTime`

s :: QuasiQuoter Source #

A quasiquoter to denote a duration in seconds. Its behavior varies according to what you give to the quasiquoter.

When a unitless number (like `42`

) is supplied to `s`

, the expression has the type of

.`AbsoluteDuration`

a => a

`>>>`

42s`[s| 42 |] :: DiffTime`

When you pass a string with a number and a valid unit (like `42s`

), the expression has the type of

, and it represents how long the given duration is in seconds.`RelativeDuration`

a => a

For example, how long is 42 minutes in seconds?

`>>>`

2520`[s| 42m |] :: Int`

Note that short durations can be rounded to zero when treated as an integer.

`>>>`

0`[s| 1ms |] :: Int`

`>>>`

0`[s| 1ms |] :: Integer`

To avoid this, use `Ratio`

or `Float`

instead.

`>>>`

1 % 1000`[s| 1ms |] :: Rational`

`>>>`

1.0e-3`[s| 1ms |] :: Float`

ms :: QuasiQuoter Source #

A quasiquoter to denote a duration in milliseconds. See `s`

for detailed usage.

`>>>`

0.042s`[ms| 42 |] :: DiffTime`

`>>>`

42000`[ms| 42s |] :: Integer`

µs :: QuasiQuoter Source #

A quasiquoter to denote a duration in microseconds. See `s`

for detailed usage.

`>>>`

0.000042s`[µs| 42 |] :: DiffTime`

`>>>`

42000000`[µs| 42s |] :: Integer`

ns :: QuasiQuoter Source #

A quasiquoter to denote a duration in nanoseconds. See `s`

for detailed usage.

`>>>`

0.000000042s`[ns| 42 |] :: DiffTime`

`>>>`

42000000000`[ns| 42s |] :: Integer`

ps :: QuasiQuoter Source #

A quasiquoter to denote a duration in picoseconds. See `s`

for detailed usage.

`>>>`

0.000000000042s`[ps| 42 |] :: DiffTime`

`>>>`

42000000000000`[ps| 42s |] :: Integer`