flick-duration-1.0.0: work with durations of time using the Flick as the smallest unit

Copyright (c) 2018 Christopher C Lord Pliosoft BSD Style experimental Safe Haskell2010

Data.Duration

Description

Maintainer : christopher@pliosoft.com Portability : GHC

Use a to contain some number of flicks, and provide standard numerical operations.

Based on idea from ChristopherHorvath

Synopsis

# The Duration type

data Duration Source #

Represents a span of time using some number of flicks. To create a Duration use:

• durationFromFlicks
• durationFromHours
• durationFromMicroseconds
• durationFromMilliseconds
• durationFromMinutes
• durationFromSeconds

Duration can be concatinated with mappend or the '(<>)' operator.

Instances
 Source # Instance detailsDefined in Data.Duration Methods Source # Instance detailsDefined in Data.Duration Methods(<) :: Duration -> Duration -> Bool #(>) :: Duration -> Duration -> Bool # Source # Instance detailsDefined in Data.Duration MethodsshowList :: [Duration] -> ShowS # Source # Instance detailsDefined in Data.Duration Methodsstimes :: Integral b => b -> Duration -> Duration # Source # Instance detailsDefined in Data.Duration Methodsmconcat :: [Duration] -> Duration #

# Constant Ratios

flicksPerMillisecond :: Num a => a Source #

Flicks are a small unit of time that are very evenly divisible by common file format time durations; i.e., for common durations they will have no rounding. Even if there is rounding, it is a very short amount of time -- 1.417 nanoseconds, so rounding is typically not a concern.

flicksPerSecond :: Num a => a Source #

How many flicks are in a second

flicksPerMinute :: Num a => a Source #

How many flicks are in a minute

flickRatio :: Fractional a => a Source #

Ratio of seconds to flicks. for example, 100 seconds of flicks is (100 * flickRatio)

Convert a Duration into flicks, stored in a Rational

Convert a Duration into seconds, stored in a Rational

# Duration to various human units

given some Duration, represent it as a count of hours

given some Duration, represent it as a count of nanoseconds

given some Duration, represent it as a count of microseconds

given some Duration, represent it as a count of milliseconds

given some Duration, represent it as a count of minutes

given some Duration, represent it as a count of seconds

present a Duration as a count of hours, minutes, seconds, ms, us

# Creating Duration from various human units

durationFromFlicks :: Integral a => a -> Duration Source #

Given a number of flicks, produce a Duration

Given a number of hours, produce a Duration

Given a number of nanoseconds, produce a Duration. Note that flicks are larger than nanoseconds, so rounding will occur

Given a number of microseconds, produce a Duration

Given a number of milliseconds, produce a Duration

Given a number of minutes, produce a Duration

Given a number of seconds, produce a Duration

# Duration from wavelength at some frequency, and vice versa

given some frequency in beats per minute, produce the Duration between beats

given some frequency in cycles per second, produce the Duration of a single wavelength's period

If Duration d is the time for one period of a wave, produce the corresponding frequency in hz.

# Duration manipulations

Repeat a Duration some rational number of times to produce the total duration

take a Duration and divide it into equal pieces of some length (the result)

given some Duration d1, how many times can we iterate that duration into another duration

given some Duration produce a negative version

Given an epsilon e and two durations, will determine their Ord with respect to the epsilon

Suspend currently running thread for a Duration of time.

Provides no exact guarantee on when the thread will be resumed after the delay.

# Measuring delay with the system clock

Holds implementation-defined start of time measurment for startMeasuring

start measuring a duration

How long since the start of measuring has it mean, plus or minus measurementEpsilon

About how accurate is are the methods durationSince and startMeasuring