buildbox-1.5.3.1: Rehackable components for writing buildbots and test harnesses.

Safe HaskellSafe-Infered

BuildBox.Aspect.Units

Contents

Description

Physical units of measure.

Synopsis

The unit types

data Bytes Source

Bytes of data.

Constructors

Bytes Integer 

IsUnits

data IsUnits a whereSource

Represents the units used for some thing.

HasUnits

class HasUnits a b | a -> b whereSource

Determine the units used by the elements of some collection, by inspecting the elements directly. Returns Nothing when applied to empty collections, as they have no units.

Methods

hasUnits :: a -> Maybe (IsUnits b)Source

Instances

WithUnits wrappers

data WithUnits t whereSource

A wrapper type used to store data of varying physical units in a homogenous collection structure.

Constructors

WithSeconds :: t Seconds -> WithUnits t 
WithBytes :: t Bytes -> WithUnits t 

Instances

(Read (t Bytes), Read (t Seconds)) => Read (WithUnits t) 
(Show (t Bytes), Show (t Seconds)) => Show (WithUnits t) 
(Pretty (t Bytes), Pretty (t Seconds)) => Pretty (WithUnits t) 

secs :: (Single Seconds -> c Single Seconds) -> Double -> WithUnits (c Single)Source

Helpful wrapper for constructing seconds-valued aspect data. Examples:

Time TotalWall `secs` 10  ::  WithUnits (Aspect Single)

bytes :: (Single Bytes -> c Single Bytes) -> Integer -> WithUnits (c Single)Source

Similar to secs.

appWithUnits :: (forall units. Real units => t1 units -> b) -> WithUnits t1 -> bSource

Apply a function to unit-wrapped data

liftWithUnits :: (forall units. Real units => t1 units -> t2 units) -> WithUnits t1 -> WithUnits t2Source

Apply a function to unit-wrapped data.

liftsWithUnits :: (forall units. Real units => [t1 units] -> [t2 units]) -> [WithUnits t1] -> [WithUnits t2]Source

Transform values of each unit type as a group.

liftsWithUnits2 :: (forall units. Real units => [t1 units] -> [t2 units] -> [t3 units]) -> [WithUnits t1] -> [WithUnits t2] -> [WithUnits t3]Source

Transform values of each unit type as a group

Unit-preserving collation

class Collatable t whereSource

Collate some data, while preserving units.

Methods

collate :: forall a. HasUnits a a => [t Single a] -> [t [] a]Source

Instances

collateWithUnits :: Collatable c => [WithUnits (c Single)] -> [WithUnits (c [])]Source

Collate some data.

 collateWithUnits  [ Time KernelCpu `secs`  5
                   , Time KernelCpu `secs`  10
                   , Time TotalWall `secs`  55
                   , Size ExeSize   `bytes` 100884
                   , Time TotalWall `secs`  52 ]
 =>
                   [ WithSeconds (Time KernelCpu [Seconds 5.0,  Seconds 10.0])
                   , WithSeconds (Time TotalWall [Seconds 55.0, Seconds 52.0])
                   , WithBytes   (Size ExeSize [Bytes 1024])]