units-2.4.1.4: A domain-specific type system for dimensional analysis
Copyright(C) 2013 Richard Eisenberg
LicenseBSD-style (see LICENSE)
MaintainerRichard Eisenberg (rae@cs.brynmawr.edu)
Stabilityexperimental
Portabilitynon-portable
Safe HaskellUnsafe
LanguageHaskell2010

Data.Metrology.Unsafe

Description

This module exports the constructor of the Qu type. This allows you to write code that takes creates and reads quantities at will, which may lead to dimension unsafety. Use at your peril.

This module also exports UnsafeQu, which is a simple wrapper around Qu that has Functor, etc., instances. The reason Qu itself doesn't have a Functor instance is that it would be unit-unsafe, allowing you, say, to add 1 to a quantity.... but 1 what? That's the problem. However, a Functor instance is likely useful, hence UnsafeQu.

Synopsis

The Qu type

newtype Qu (a :: [Factor *]) (lcsu :: LCSU *) (n :: *) Source #

Qu adds a dimensional annotation to its numerical value type n. This is the representation for all quantities.

Constructors

Qu n 

Instances

Instances details
Eq n => Eq (Qu d l n) Source # 
Instance details

Defined in Data.Metrology.Qu

Methods

(==) :: Qu d l n -> Qu d l n -> Bool #

(/=) :: Qu d l n -> Qu d l n -> Bool #

(d ~ ('[] :: [Factor Type]), Floating n) => Floating (Qu d l n) Source # 
Instance details

Defined in Data.Metrology.Qu

Methods

pi :: Qu d l n #

exp :: Qu d l n -> Qu d l n #

log :: Qu d l n -> Qu d l n #

sqrt :: Qu d l n -> Qu d l n #

(**) :: Qu d l n -> Qu d l n -> Qu d l n #

logBase :: Qu d l n -> Qu d l n -> Qu d l n #

sin :: Qu d l n -> Qu d l n #

cos :: Qu d l n -> Qu d l n #

tan :: Qu d l n -> Qu d l n #

asin :: Qu d l n -> Qu d l n #

acos :: Qu d l n -> Qu d l n #

atan :: Qu d l n -> Qu d l n #

sinh :: Qu d l n -> Qu d l n #

cosh :: Qu d l n -> Qu d l n #

tanh :: Qu d l n -> Qu d l n #

asinh :: Qu d l n -> Qu d l n #

acosh :: Qu d l n -> Qu d l n #

atanh :: Qu d l n -> Qu d l n #

log1p :: Qu d l n -> Qu d l n #

expm1 :: Qu d l n -> Qu d l n #

log1pexp :: Qu d l n -> Qu d l n #

log1mexp :: Qu d l n -> Qu d l n #

(d ~ ('[] :: [Factor Type]), Fractional n) => Fractional (Qu d l n) Source # 
Instance details

Defined in Data.Metrology.Qu

Methods

(/) :: Qu d l n -> Qu d l n -> Qu d l n #

recip :: Qu d l n -> Qu d l n #

fromRational :: Rational -> Qu d l n #

(d ~ ('[] :: [Factor Type]), Num n) => Num (Qu d l n) Source # 
Instance details

Defined in Data.Metrology.Qu

Methods

(+) :: Qu d l n -> Qu d l n -> Qu d l n #

(-) :: Qu d l n -> Qu d l n -> Qu d l n #

(*) :: Qu d l n -> Qu d l n -> Qu d l n #

negate :: Qu d l n -> Qu d l n #

abs :: Qu d l n -> Qu d l n #

signum :: Qu d l n -> Qu d l n #

fromInteger :: Integer -> Qu d l n #

Ord n => Ord (Qu d l n) Source # 
Instance details

Defined in Data.Metrology.Qu

Methods

compare :: Qu d l n -> Qu d l n -> Ordering #

(<) :: Qu d l n -> Qu d l n -> Bool #

(<=) :: Qu d l n -> Qu d l n -> Bool #

(>) :: Qu d l n -> Qu d l n -> Bool #

(>=) :: Qu d l n -> Qu d l n -> Bool #

max :: Qu d l n -> Qu d l n -> Qu d l n #

min :: Qu d l n -> Qu d l n -> Qu d l n #

Read n => Read (Qu ('[] :: [Factor Type]) l n) Source # 
Instance details

Defined in Data.Metrology.Qu

Methods

readsPrec :: Int -> ReadS (Qu '[] l n) #

readList :: ReadS [Qu '[] l n] #

readPrec :: ReadPrec (Qu '[] l n) #

readListPrec :: ReadPrec [Qu '[] l n] #

(d ~ ('[] :: [Factor Type]), Real n) => Real (Qu d l n) Source # 
Instance details

Defined in Data.Metrology.Qu

Methods

toRational :: Qu d l n -> Rational #

(d ~ ('[] :: [Factor Type]), RealFloat n) => RealFloat (Qu d l n) Source # 
Instance details

Defined in Data.Metrology.Qu

Methods

floatRadix :: Qu d l n -> Integer #

floatDigits :: Qu d l n -> Int #

floatRange :: Qu d l n -> (Int, Int) #

decodeFloat :: Qu d l n -> (Integer, Int) #

encodeFloat :: Integer -> Int -> Qu d l n #

exponent :: Qu d l n -> Int #

significand :: Qu d l n -> Qu d l n #

scaleFloat :: Int -> Qu d l n -> Qu d l n #

isNaN :: Qu d l n -> Bool #

isInfinite :: Qu d l n -> Bool #

isDenormalized :: Qu d l n -> Bool #

isNegativeZero :: Qu d l n -> Bool #

isIEEE :: Qu d l n -> Bool #

atan2 :: Qu d l n -> Qu d l n -> Qu d l n #

(d ~ ('[] :: [Factor Type]), RealFrac n) => RealFrac (Qu d l n) Source # 
Instance details

Defined in Data.Metrology.Qu

Methods

properFraction :: Integral b => Qu d l n -> (b, Qu d l n) #

truncate :: Integral b => Qu d l n -> b #

round :: Integral b => Qu d l n -> b #

ceiling :: Integral b => Qu d l n -> b #

floor :: Integral b => Qu d l n -> b #

Show n => Show (Qu ('[] :: [Factor Type]) l n) Source # 
Instance details

Defined in Data.Metrology.Qu

Methods

showsPrec :: Int -> Qu '[] l n -> ShowS #

show :: Qu '[] l n -> String #

showList :: [Qu '[] l n] -> ShowS #

(ShowUnitFactor (LookupList dims lcsu), Show n) => Show (Qu dims lcsu n) Source # 
Instance details

Defined in Data.Metrology.Show

Methods

showsPrec :: Int -> Qu dims lcsu n -> ShowS #

show :: Qu dims lcsu n -> String #

showList :: [Qu dims lcsu n] -> ShowS #

NFData n => NFData (Qu d l n) Source # 
Instance details

Defined in Data.Metrology.Qu

Methods

rnf :: Qu d l n -> () #

VectorSpace n => VectorSpace (Qu d l n) Source # 
Instance details

Defined in Data.Metrology.Qu

Associated Types

type Scalar (Qu d l n) #

Methods

(*^) :: Scalar (Qu d l n) -> Qu d l n -> Qu d l n #

AdditiveGroup n => AdditiveGroup (Qu d l n) Source # 
Instance details

Defined in Data.Metrology.Qu

Methods

zeroV :: Qu d l n #

(^+^) :: Qu d l n -> Qu d l n -> Qu d l n #

negateV :: Qu d l n -> Qu d l n #

(^-^) :: Qu d l n -> Qu d l n -> Qu d l n #

ValidDL d l => Quantity (Qu d l n) Source # 
Instance details

Defined in Data.Metrology.Quantity

Associated Types

type QuantityUnit (Qu d l n) Source #

type QuantityLCSU (Qu d l n) :: LCSU Type Source #

type QuantityRep (Qu d l n) Source #

Methods

fromQuantity :: QuantityQu (Qu d l n) -> Qu d l n Source #

toQuantity :: Qu d l n -> QuantityQu (Qu d l n) Source #

type Scalar (Qu d l n) Source # 
Instance details

Defined in Data.Metrology.Qu

type Scalar (Qu d l n) = Scalar n
type QuantityUnit (Qu d l n) Source # 
Instance details

Defined in Data.Metrology.Quantity

type QuantityUnit (Qu d l n) = UnitOfDimFactors d l
type QuantityLCSU (Qu d l n) Source # 
Instance details

Defined in Data.Metrology.Quantity

type QuantityLCSU (Qu d l n) = l
type QuantityRep (Qu d l n) Source # 
Instance details

Defined in Data.Metrology.Quantity

type QuantityRep (Qu d l n) = n
type (Qu d l n) %^ z Source # 
Instance details

Defined in Data.Metrology.Qu

type (Qu d l n) %^ z = Qu (d @* z) l n
type (Qu d1 l n) %/ (Qu d2 l n) Source # 
Instance details

Defined in Data.Metrology.Qu

type (Qu d1 l n) %/ (Qu d2 l n) = Qu (d1 @- d2) l n
type (Qu d1 l n) %* (Qu d2 l n) Source # 
Instance details

Defined in Data.Metrology.Qu

type (Qu d1 l n) %* (Qu d2 l n) = Qu (d1 @+ d2) l n

UnsafeQu

newtype UnsafeQu d l n Source #

A basic wrapper around Qu that has more instances.

Constructors

UnsafeQu 

Fields

Instances

Instances details
Functor (UnsafeQu d l) Source # 
Instance details

Defined in Data.Metrology.Unsafe

Methods

fmap :: (a -> b) -> UnsafeQu d l a -> UnsafeQu d l b #

(<$) :: a -> UnsafeQu d l b -> UnsafeQu d l a #

Applicative (UnsafeQu d l) Source # 
Instance details

Defined in Data.Metrology.Unsafe

Methods

pure :: a -> UnsafeQu d l a #

(<*>) :: UnsafeQu d l (a -> b) -> UnsafeQu d l a -> UnsafeQu d l b #

liftA2 :: (a -> b -> c) -> UnsafeQu d l a -> UnsafeQu d l b -> UnsafeQu d l c #

(*>) :: UnsafeQu d l a -> UnsafeQu d l b -> UnsafeQu d l b #

(<*) :: UnsafeQu d l a -> UnsafeQu d l b -> UnsafeQu d l a #

Foldable (UnsafeQu d l) Source # 
Instance details

Defined in Data.Metrology.Unsafe

Methods

fold :: Monoid m => UnsafeQu d l m -> m #

foldMap :: Monoid m => (a -> m) -> UnsafeQu d l a -> m #

foldMap' :: Monoid m => (a -> m) -> UnsafeQu d l a -> m #

foldr :: (a -> b -> b) -> b -> UnsafeQu d l a -> b #

foldr' :: (a -> b -> b) -> b -> UnsafeQu d l a -> b #

foldl :: (b -> a -> b) -> b -> UnsafeQu d l a -> b #

foldl' :: (b -> a -> b) -> b -> UnsafeQu d l a -> b #

foldr1 :: (a -> a -> a) -> UnsafeQu d l a -> a #

foldl1 :: (a -> a -> a) -> UnsafeQu d l a -> a #

toList :: UnsafeQu d l a -> [a] #

null :: UnsafeQu d l a -> Bool #

length :: UnsafeQu d l a -> Int #

elem :: Eq a => a -> UnsafeQu d l a -> Bool #

maximum :: Ord a => UnsafeQu d l a -> a #

minimum :: Ord a => UnsafeQu d l a -> a #

sum :: Num a => UnsafeQu d l a -> a #

product :: Num a => UnsafeQu d l a -> a #

Traversable (UnsafeQu d l) Source # 
Instance details

Defined in Data.Metrology.Unsafe

Methods

traverse :: Applicative f => (a -> f b) -> UnsafeQu d l a -> f (UnsafeQu d l b) #

sequenceA :: Applicative f => UnsafeQu d l (f a) -> f (UnsafeQu d l a) #

mapM :: Monad m => (a -> m b) -> UnsafeQu d l a -> m (UnsafeQu d l b) #

sequence :: Monad m => UnsafeQu d l (m a) -> m (UnsafeQu d l a) #