Copyright | (C) 2014 Richard Eisenberg |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | Richard Eisenberg (eir@cis.upenn.edu) |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Exports a class Quantity
to allow easy conversion between proper
quantities and types from other libraries.
- class Quantity t where
- type QuantityUnit t :: *
- type QuantityLCSU t :: LCSU *
- type QuantityRep t :: *
- fromQuantity :: QuantityQu t -> t
- toQuantity :: t -> QuantityQu t
- type QuantityQu t = MkQu_ULN (QuantityUnit t) (QuantityLCSU t) (QuantityRep t)
Documentation
Quantity
allows for easy conversions in and out of quantities. For example,
say you are working with an outside library for time that defines UTCTime
, where
that stores the time measured in seconds. You could say
instance Quantity UTCTime where type QuantityUnit = Second fromQuantity = ... toQuantity = ...
Then, conversions are easy and unit-safe.
type QuantityUnit t :: * Source
The unit associated with t
.
type QuantityLCSU t :: LCSU * Source
The LCSU associated with t
. Defaults to DefaultLCSU
.
type QuantityRep t :: * Source
The numerical representation associated with t
. Defaults to Double
.
fromQuantity :: QuantityQu t -> t Source
toQuantity :: t -> QuantityQu t Source
type QuantityQu t = MkQu_ULN (QuantityUnit t) (QuantityLCSU t) (QuantityRep t) Source