MyNixOS website logo
Description

Use a time unit class, but hold a concrete time type.

Two common ways to represent and hold short time intervals seem to be:

  1. Hold time in microseconds as an Int or Integer

  2. 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.

See the .cabal file for more info and link to project website the version control.

The official download location is Hackage:

http://hackage.haskell.org/package/time-interval

This library is free software, and is committed to software freedom. It is released to the public domain using the CC0 Public Domain Dedication. For the boring "legal" details see the file 'COPYING'.

See the file 'INSTALL' for hints on installation. The file 'ChangeLog' explains how to see the history log of the changes done in the code. 'NEWS' provides a friendly overview of the changes for each release.

Metadata

Version

0.1.1

License

publicDomain

Platforms (75)

    Darwin
    FreeBSD 13
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd13
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd13
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows