time-interval: Use a time unit class, but hold a concrete time type.
Two common ways to represent and hold short time intervals seem to be:
Hold time in microseconds as an
Int
orInteger
Use time units abstraction, e.g. see the time-units package
While the second option is a great abstraction to use in APIs, it works for
datatypes a bit less well than for function types. That's because a datatype
which a Data.Time.Units.TimeUnit
field suddenly becomes polymorphic over
that field, and all function type signatures involving that datatype need to
be updated. This is less an issue for functions, because you don't specify
the type of every function at the call site.
Perhaps there is a solution for that which involves datatype related
language extensions, but this package tries to offer a simple clean solution
as follows. You store time in your datatype as an integer, but it is wrapped
by an opaque Data.Time.Interval.TimeInterval
type. You then get the best of
both worlds:
On one hand, you can set the time field using any time unit thanks to the time-units package, so you get a nice abstraction
On the other hand, your datatype holds a concrete time type
The time type can be equally used to represent time intervals, time durations
and generally time lengths. But since high precision is used (microseconds),
you'll probably want this library for short time lengths (at most seconds,
minutes, hours). For calendar based and related time functions and types, see
the time
package.
[Skip to Readme]
Downloads
- time-interval-0.1.1.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Versions [RSS] | 0.1.0.0, 0.1.1 |
---|---|
Change log | ChangeLog |
Dependencies | base (>=4.7 && <5), time-units [details] |
License | LicenseRef-PublicDomain |
Copyright | ♡ Copying is an act of love. Please copy, reuse and share. |
Author | fr33domlover |
Maintainer | fr33domlover@riseup.net |
Category | Data |
Home page | http://hub.darcs.net/fr33domlover/time-interval |
Bug tracker | mailto:fr33domlover@riseup.net |
Source repo | head: darcs get http://hub.darcs.net/fr33domlover/time-interval |
Uploaded | by akrasner at 2016-05-30T06:56:54Z |
Distributions | NixOS:0.1.1 |
Reverse Dependencies | 3 direct, 1 indirect [details] |
Downloads | 4951 total (20 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs available [build log] Last success reported on 2016-05-30 [all 1 reports] |