Commits

Thijs Alkemade  committed 67e785b

Reordered Value f a b into Value a b f, so many typeclasses can be defined over the enclosed value.

Added instances for Functor, Monad, Applicative, Monoid, Foldable and Traversable, because they can be easily defined. For most I'm not sure if they're useful, as they limit the used values to the same dimension and unit.

  • Participants
  • Parent commits 9fe618a

Comments (0)

Files changed (12)

File src/UnitTyped.hs

         POne, PTwo, PThree, PFour, PFive, PSix,
         NOne, NTwo, NThree, NFour,
 
-        coerce, as, to, one, mkVal, val, mapVal, (|*|), (|/|), (|+|), (|-|),
+        coerce, as, to, one, mkVal, val, (|*|), (|/|), (|+|), (|-|),
         (*|), (|*), (|/), (/|), (|+), (+|), (|-), (-|),
         (|==|), (|<=|), (|<|), (|>=|), (|>|),
 
         square, cubic
 ) where
 
+import Control.Applicative
+import Data.Monoid
+import Data.Foldable
+import Data.Traversable
+
 -- |Type level natural numbers (excluding zero, though).
 data Nat = One | Suc Nat
 
 instance (MapNeg map2 map2', MapMerge map1 map2' sum, MapNull sum b) => MapEq map1 map2 b
 
 -- |A value tagged with its dimension a and unit b.
-data Value f (a :: [(*, Number)]) (b :: [(*, Number)]) = Value f
+data Value (a :: [(*, Number)]) (b :: [(*, Number)]) f = Value f
 -- |Used as fake argument for the 'Convertible' class.
 data ValueProxy (a :: [(*, Number)]) b
 -- |Used as fake argument for the 'Convertible'' class.
 data NumberProxy (a :: Number)
 
 -- |Obtain a 'ValueProxy'' from a 'Value'.
-proxy' :: (Convertible' a b) => Value f a b -> ValueProxy' a b
+proxy' :: (Convertible' a b) => Value a b f -> ValueProxy' a b
 proxy' _ = error "proxy'"
 
 class FromNumber (a :: Number) where
 toSuperScript '-' = '\8315'
 toSuperScript x = x
 
-instance (Fractional f, Show f, Convertible' a b) => Show (Value f a b) where
+instance (Fractional f, Show f, Convertible' a b) => Show (Value a b f) where
         show u = show (val u) ++ " " ++ showunit' (proxy' u)
 
 -- |coerce something of a specific dimension into any other unit in the same dimension.
 --
 -- >>> coerce (120 *| meter / second) (kilo meter / hour)
 -- 432.0 km/h
-coerce :: (Convertible' a b, Convertible' c d, Fractional f, MapEq a c True) => Value f a b -> Value f c d -> Value f c d
+coerce :: (Convertible' a b, Convertible' c d, Fractional f, MapEq a c True) => Value a b f -> Value c d f -> Value c d f
 coerce u _ = let result = mkVal (factor' (proxy' u) * val u / factor' (proxy' result)) in result
 
 infixl 5 `as`
 
 -- |Shorthand for 'coerce'.
-as :: (Convertible' a b, Convertible' c d, Fractional f, MapEq a c True) => Value f a b -> Value f c d -> Value f c d
+as :: (Convertible' a b, Convertible' c d, Fractional f, MapEq a c True) => Value a b f -> Value c d f -> Value c d f
 as = coerce
 
 -- |Shorthand for 'flip' 'coerce'
-to :: (Convertible' a b, Convertible' c d, Fractional f, MapEq a c True) => Value f c d -> Value f a b -> Value f c d
+to :: (Convertible' a b, Convertible' c d, Fractional f, MapEq a c True) => Value c d f -> Value a b f -> Value c d f
 to = flip coerce
 
 infixl 7 |*|, |/|
 
 -- |Multiply two values, constructing a value with as dimension the product of the dimensions,
 -- and as unit the multplication of the units.
-(|*|) :: (Fractional f, Convertible' a b, Convertible' c d, MapMerge a c u, MapMerge b d s) => Value f a b -> Value f c d -> Value f u s
+(|*|) :: (Fractional f, Convertible' a b, Convertible' c d, MapMerge a c u, MapMerge b d s) => Value a b f -> Value c d f -> Value u s f
 a |*| b = mkVal (val a * val b)
 
 -- |Divide two values, constructing a value with as dimension the division of the dimension of the lhs by the dimension of the rhs,
 -- and the same for the units.
-(|/|), per :: (Fractional f, Convertible' a b, Convertible' c d, MapMerge a c' u, MapNeg c c', MapNeg d d', MapMerge b d' s) => Value f a b -> Value f c d -> Value f u s
+(|/|), per :: (Fractional f, Convertible' a b, Convertible' c d, MapMerge a c' u, MapNeg c c', MapNeg d d', MapMerge b d' s) => Value a b f -> Value c d f -> Value u s f
 a |/| b = mkVal (val a / val b)
 per = (|/|)
 
 -- |Add two values with matching dimensions. Units are automatically resolved. The result will have the same unit as the lhs.
-(|+|) :: (Fractional f, Convertible' a b, Convertible' c d, MapEq c a True) => Value f a b -> Value f c d -> Value f a b
+(|+|) :: (Fractional f, Convertible' a b, Convertible' c d, MapEq c a True) => Value a b f -> Value c d f -> Value a b f
 a |+| b = mkVal (val a + val (coerce b a))
 
 -- |Subtract two values with matching dimensions. Units are automatically resolved. The result will have the same unit as the lhs.
-(|-|) :: (Fractional f, Convertible' a b, Convertible' c d, MapEq c a True) => Value f a b -> Value f c d -> Value f a b
+(|-|) :: (Fractional f, Convertible' a b, Convertible' c d, MapEq c a True) => Value a b f -> Value c d f -> Value a b f
 a |-| b = mkVal (val a - val (coerce b a))
 
 infixl 9 *|, |*, |/, /|
 infixl 8 +|, |+, -|, |-
 
 -- |Multiply a scalar by a unit.
-(*|) :: (Convertible' a b, Fractional f) => f -> Value f a b -> Value f a b
+(*|) :: (Convertible' a b, Fractional f) => f -> Value a b f -> Value a b f
 d *| u = mkVal (d * val u)
 
 -- |Multiply a unit by a scalar.
-(|*) :: (Convertible' a b, Fractional f) => Value f a b -> f -> Value f a b
+(|*) :: (Convertible' a b, Fractional f) => Value a b f -> f -> Value a b f
 u |* d = mkVal (val u * d)
 
 -- |Divide a scalar by a unit.
-(/|) :: (Convertible' a b, Fractional f, MapNeg a a', MapNeg b b') => f -> Value f a b -> Value f a' b'
+(/|) :: (Convertible' a b, Fractional f, MapNeg a a', MapNeg b b') => f -> Value a b f -> Value a' b' f
 d /| u = mkVal (d / val u)
 
 -- |Divide a unit by a scalar.
-(|/) :: (Convertible' a b, Fractional f) => Value f a b -> f -> Value f a b
+(|/) :: (Convertible' a b, Fractional f) => Value a b f -> f -> Value a b f
 u |/ d = mkVal (val u / d)
 
 -- |Add a unit to a scalar.
-(+|) :: (Convertible' a b, Fractional f) => f -> Value f a b -> Value f a b
+(+|) :: (Convertible' a b, Fractional f) => f -> Value a b f -> Value a b f
 d +| u = mkVal (d + val u)
 
 -- |Add a scalar to a unit.
-(|+) :: (Convertible' a b, Fractional f) => Value f a b -> f -> Value f a b
+(|+) :: (Convertible' a b, Fractional f) => Value a b f -> f -> Value a b f
 u |+ d = mkVal (val u + d)
 
 -- |Subtract a unit from a scalar.
-(-|) :: (Convertible' a b, Fractional f) => f -> Value f a b -> Value f a b
+(-|) :: (Convertible' a b, Fractional f) => f -> Value a b f -> Value a b f
 d -| u = mkVal (d - val u)
 
 -- |Subtract a scalar from a unit.
-(|-) :: (Convertible' a b, Fractional f) => Value f a b -> f -> Value f a b
+(|-) :: (Convertible' a b, Fractional f) => Value a b f -> f -> Value a b f
 u |- d = mkVal (val u - d)
 
 -- |Create a new value with given scalar as value.
-mkVal :: (Fractional f) => f -> Value f a b
+mkVal :: f -> Value a b f
 mkVal = Value
 
 -- |Obtain the value of a value wrapped in a type.
-val :: (Fractional f) => Value f a b -> f
+val :: Value a b f -> f
 val (Value f) = f
 
--- |Map over values. The 'Fractional' constraints make it impossible to define a 'Functor' instance, therefore this.
-mapVal :: (Fractional f, Fractional g) => (f -> g) -> Value f a b -> Value g a b
-mapVal f = mkVal . f . val
+instance Functor (Value a b) where
+    fmap f = mkVal . f . val
+
+instance Monad (Value a b) where
+    x >>= f = f $ val x
+    return = mkVal
+
+instance Applicative (Value a b) where
+    pure = mkVal
+    f <*> x = mkVal $ (val f) (val x)
+
+instance (Convertible' a b, Fractional f) => Monoid (Value a b f) where
+    mempty = mkVal 0
+    mappend = (|+|)
+
+instance Foldable (Value a b) where
+    foldMap f x = f $ val x
+
+instance Traversable (Value a b) where
+    traverse f x = mkVal <$> (f $ val x)
 
 -- |A wrapped value with scalar value 1.
-one :: (Fractional f, Convertible' a b) => Value f a b
+one :: (Fractional f, Convertible' a b) => Value a b f
 one = mkVal 1
 
 -- |Calculate the square of a value. Identical to pow2, reads better on units:
 --
 -- >>> 100 *| square meter `as` square yard
 -- 119.59900463010803 yd⋅yd⋅#
-square :: (Fractional f, MapMerge c c u, MapMerge d d s, Convertible' c d) => Value f c d -> Value f u s
+square :: (Fractional f, MapMerge c c u, MapMerge d d s, Convertible' c d) => Value c d f -> Value u s f
 square x = x |*| x
 
 -- |Calculate the third power of a value. Identical to pow3, reads better on units:
 --
 -- >>> 1 *| cubic inch `as` mili liter
 -- 16.387063999999995 mL
-cubic   :: (Fractional f, MapMerge a c u, MapMerge b d s, MapMerge c c a, MapMerge d d b, Convertible' a b, Convertible' c d) => Value f c d -> Value f u s
+cubic :: (Fractional f, MapMerge a c u, MapMerge b d s, MapMerge c c a, MapMerge d d b, Convertible' a b, Convertible' c d) => Value c d f -> Value u s f
 cubic x = x |*| x |*| x
 
-wrapB :: (Convertible' a b, Convertible' c d, MapEq c a True) => (Rational -> Rational -> Bool) -> Value Rational a b -> Value Rational c d -> Bool
+wrapB :: (Convertible' a b, Convertible' c d, MapEq c a True) => (Rational -> Rational -> Bool) -> Value a b Rational -> Value c d Rational -> Bool
 wrapB op a b = op (val a) (val $ coerce b a)
 
 infixl 4 |==|, |<|, |>|, |<=|, |>=|
 
-(|==|), (|<|), (|>|), (|<=|), (|>=|) :: (Convertible' a b, Convertible' c d, MapEq c a True) => Value Rational a b -> Value Rational c d -> Bool
+(|==|), (|<|), (|>|), (|<=|), (|>=|) :: (Convertible' a b, Convertible' c d, MapEq c a True) => Value a b Rational -> Value c d Rational -> Bool
 -- |'==' for values. Only defined for values with rational contents. Can be used on any two values with the same dimension.
 (|==|) = wrapB (==)
 -- |'<' on values. Only defined for values with rational contents. Can be used on any two values with the same dimension.

File src/UnitTyped/Bytes.hs

 --
 
 -- |One byte.
-byte :: (Fractional f) => Value f DataDimension (Unit Byte)
+byte :: (Fractional f) => Value DataDimension (Unit Byte) f
 byte = one
 
 -- |One bit.
-bit :: (Fractional f) => Value f DataDimension (Unit Bit)
+bit :: (Fractional f) => Value DataDimension (Unit Bit) f
 bit = one

File src/UnitTyped/NoPrelude.hs

 import UnitTyped.SI.Derived.Count
 
 import qualified Prelude
-import Prelude (Show(..), Fractional, Floating, ($), (.), (++), Double, const, Bool(..), otherwise, undefined, String(..), error)
+import Prelude (Show(..), Fractional, Floating, ($), (.), (++), Double, const, Bool(..), otherwise, undefined, String(..), error, fmap)
 
 infixl 6 +, -
 infixl 7 *, /
 
 -- |See '|*|'
-(*) :: (Fractional f, Convertible' a b, Convertible' c d, MapMerge a c u, MapMerge b d s) => Value f a b -> Value f c d -> Value f u s
+(*) :: (Fractional f, Convertible' a b, Convertible' c d, MapMerge a c u, MapMerge b d s) => Value a b f -> Value c d f -> Value u s f
 (*) = (|*|)
 
 -- |See '|/|'
-(/) :: (Fractional f, Convertible' a b, Convertible' c d, MapMerge a c' u, MapNeg c c', MapNeg d d', MapMerge b d' s) => Value f a b -> Value f c d -> Value f u s
+(/) :: (Fractional f, Convertible' a b, Convertible' c d, MapMerge a c' u, MapNeg c c', MapNeg d d', MapMerge b d' s) => Value a b f -> Value c d f -> Value u s f
 (/) = (|/|)
 
 -- |See '|+|'
-(+) :: (Fractional f, Convertible' a b, Convertible' c d, MapEq c a True) => Value f a b -> Value f c d -> Value f a b
+(+) :: (Fractional f, Convertible' a b, Convertible' c d, MapEq c a True) => Value a b f -> Value c d f -> Value a b f
 (+) = (|+|)
 
 -- |See '|-|'
-(-) :: (Fractional f, Convertible' a b, Convertible' c d, MapEq c a True) => Value f a b -> Value f c d -> Value f a b
+(-) :: (Fractional f, Convertible' a b, Convertible' c d, MapEq c a True) => Value a b f -> Value c d f -> Value a b f
 (-) = (|-|)
 
-wrap1 :: (Floating f, Convertible' '[] b) => (f -> f) -> Value f '[] b -> Value f '[] '[]
+wrap1 :: (Floating f, Convertible' '[] b) => (f -> f) -> Value '[] b f -> Value '[] '[] f
 wrap1 op v = op (val $ coerce v rad) *| one
 
-sin, cos, tan :: (Floating f, Convertible' '[] b) => Value f '[] b -> Value f '[] '[]
+sin, cos, tan :: (Floating f, Convertible' '[] b) => Value '[] b f -> Value '[] '[] f
 -- |Calculate the sinus of a value. Works on 'Degree' and 'Radian'.
 sin = wrap1 Prelude.sin
 -- |Calculate the cosinus of a value. Works on 'Degree' and 'Radian'.
 -- |Calculate the tangens of a value. Works on 'Degree' and 'Radian'.
 tan = wrap1 Prelude.tan
 
-wrap2 :: (Floating f) => (f -> f) -> Value f '[] '[] -> Value f '[] (Unit Radian)
+wrap2 :: (Floating f) => (f -> f) -> Value '[] '[] f -> Value '[] (Unit Radian) f
 wrap2 op v = op (val v) *| one
 
-asin, acos, atan :: (Floating f) => Value f '[] '[] -> Value f '[] (Unit Radian)
+asin, acos, atan :: (Floating f) => Value '[] '[] f -> Value '[] (Unit Radian) f
 -- |Calculate the arcsinus of a value. Always computes 'Radian's.
 asin = wrap2 Prelude.asin
 -- |Calculate the arccosinus of a value. Always computes 'Radian's.
 
 infixl 5 ==, <, <=, >, >=
 
-(==), (<), (<=), (>), (>=) :: (Convertible' a b, Convertible' c d, MapEq c a 'True) => Value Prelude.Rational a b -> Value Prelude.Rational c d -> Bool
+(==), (<), (<=), (>), (>=) :: (Convertible' a b, Convertible' c d, MapEq c a 'True) => Value a b Prelude.Rational -> Value c d Prelude.Rational -> Bool
 -- |See '|==|'
 (==) = (|==|)
 -- |See '|<|'
 (>=) = (|>=|)
 
 -- |Obtain the 'Prelude.floor' of a value.
-floor :: (Prelude.RealFrac f) => Value f a b -> Value f a b
-floor = mapVal (Prelude.fromInteger . Prelude.floor)
+floor :: (Prelude.RealFrac f) => Value a b f -> Value a b f
+floor = fmap (Prelude.fromInteger . Prelude.floor)
 
 -- |Obtain @x - floor x@ of a value.
-diff :: (Convertible' a b, Prelude.RealFrac f) => Value f a b -> Value f a b
+diff :: (Convertible' a b, Prelude.RealFrac f) => Value a b f -> Value a b f
 diff x = x |-| (floor x)
 
 -- |Obtain the 'Prelude.abs' of a value.
-abs :: (Fractional f) => Value f a b -> Value f a b
-abs = mapVal Prelude.abs
+abs :: (Fractional f) => Value a b f -> Value a b f
+abs = fmap Prelude.abs

File src/UnitTyped/SI.hs

 ----
 
 -- |One thing (#).
-count :: (Fractional f) => Value f '[] '[]
+count :: (Fractional f) => Value '[] '[] f
 count = one
 
 -- |One mole (mol).
-mole :: (Fractional f) => Value f '[] '[]
+mole :: (Fractional f) => Value '[] '[] f
 mole = one
 
 --
 
 -- |One meter (m).
-meter :: (Fractional f) => Value f LengthDimension (Unit Meter)
+meter :: (Fractional f) => Value LengthDimension (Unit Meter) f
 meter = one
 
 --
 
 -- |One second (s).
-second :: (Fractional f) => Value f TimeDimension (Unit Second)
+second :: (Fractional f) => Value TimeDimension (Unit Second) f
 second = one
 
 --
 
 -- |One gram (g).
-gram :: (Fractional f) => Value f MassDimension (Unit Gram)
+gram :: (Fractional f) => Value MassDimension (Unit Gram) f
 gram = one
 
 --
 
 -- |One Kelvin (K).
-kelvin :: (Fractional f) => Value f TemperatureDimension (Unit Kelvin)
+kelvin :: (Fractional f) => Value TemperatureDimension (Unit Kelvin) f
 kelvin = one
 
 --
 
 -- |One ampere (A).
-ampere :: (Fractional f) => Value f CurrentDimension (Unit Ampere)
+ampere :: (Fractional f) => Value CurrentDimension (Unit Ampere) f
 ampere = one
 
 --
 
 -- |One candela (cd).
-candela :: (Fractional f) => Value f LuminousDimension (Unit Candela)
+candela :: (Fractional f) => Value LuminousDimension (Unit Candela) f
 candela = one

File src/UnitTyped/SI/Constants.hs

 import UnitTyped.SI.Derived
 
 -- |π as the floating point value it has in the "Prelude".
-pi' :: (Fractional f, Floating f) => Value f '[] '[]
+pi' :: (Fractional f, Floating f) => Value '[] '[] f
 pi' = mkVal Prelude.pi
 
 -- |π as a rational value. Which it isn't. But we can pretend it is.
-pi :: (Fractional f) => Value f '[] '[]
+pi :: (Fractional f) => Value '[] '[] f
 pi = mkVal 3.1415926535897932384626433832795028841971
 
 -- |The speed of light
-c :: (Fractional f) => Value f Speed '[ '(Second, NOne), '(Meter, POne)]
+c :: (Fractional f) => Value Speed '[ '(Second, NOne), '(Meter, POne)] f
 c = mkVal 299792458
 
 -- |Planck constant
-h :: Fractional f => Value f '[ '(Time, ('Neg 'One)), '(Mass, ('Pos 'One)), '(Length, ('Pos ('Suc 'One))) ] '[ '(Joule, ('Pos 'One)), '(Second, ('Pos 'One)) ]
+h :: Fractional f => Value '[ '(Time, ('Neg 'One)), '(Mass, ('Pos 'One)), '(Length, ('Pos ('Suc 'One))) ] '[ '(Joule, ('Pos 'One)), '(Second, ('Pos 'One)) ] f
 h = mkVal 6.6260695729e-34
 
 -- |Reduced Planck constant
-hbar :: Fractional f => Value f '[ '(Time, NOne), '(Length, PTwo), '(Mass, POne)] '[ '(Second, POne), '(Joule, POne) ]
+hbar :: Fractional f => Value '[ '(Time, NOne), '(Length, PTwo), '(Mass, POne)] '[ '(Second, POne), '(Joule, POne) ] f
 hbar = coerce (h |/| (2 *| UnitTyped.SI.Constants.pi)) (joule |*| second)
 
 -- |Atomic unit of charge (elementary charge)
-e :: (Fractional f) => Value f Charge (Unit Coulomb)
+e :: (Fractional f) => Value Charge (Unit Coulomb) f
 e = mkVal 1.6021765314e-19
 
 -- |Atomic unit of mass (electron mass)
-m_e :: (Fractional f) => Value f MassDimension (Unit (Kilo Gram))
+m_e :: (Fractional f) => Value MassDimension (Unit (Kilo Gram)) f
 m_e = mkVal 9.109382616e-31
 
 -- |Atomic unit of length
-a_0 :: (Fractional f) => Value f LengthDimension (Unit Meter)
+a_0 :: (Fractional f) => Value LengthDimension (Unit Meter) f
 a_0 = mkVal 0.529177210818e-10
 
 -- |Atomic unit of energy
-e_h :: (Fractional f) => Value f Energy (Unit Joule)
+e_h :: (Fractional f) => Value Energy (Unit Joule) f
 e_h = mkVal 4.3597441775e-18
 
 -- |Gas constant.
-r :: (Fractional f) => Value f '[ '(Temperature, NOne), '(Length, PTwo), '(Mass, POne), '(Time, NTwo) ] '[ '(Mole, NOne), '(Kelvin, NOne), '(Joule, POne) ]
+r :: (Fractional f) => Value '[ '(Temperature, NOne), '(Length, PTwo), '(Mass, POne), '(Time, NTwo) ] '[ '(Mole, NOne), '(Kelvin, NOne), '(Joule, POne) ] f
 r = mkVal 8.314462175
 
 -- |Gravitational constant
-g :: (Fractional f) => Value f '[ '(Time, NTwo), '(Length, PThree), '(Mass, NOne) ] '[ '(Second, NTwo), '(Meter, PThree), '((Kilo Gram), NOne) ]
+g :: (Fractional f) => Value '[ '(Time, NTwo), '(Length, PThree), '(Mass, NOne) ] '[ '(Second, NTwo), '(Meter, PThree), '((Kilo Gram), NOne) ] f
 g = mkVal 6.6738480e-11
 
 ---- |Planck mass

File src/UnitTyped/SI/Derived.hs

 --
 
 -- |One knot.
-knot :: (Fractional f) => Value f Speed (Unit Knot)
+knot :: (Fractional f) => Value Speed (Unit Knot) f
 knot = one
 
 -- |One newton.
-newton :: (Fractional f) => Value f '[ '(Time, NTwo), '(Mass, POne), '(Length, POne)] (Unit Newton)
+newton :: (Fractional f) => Value '[ '(Time, NTwo), '(Mass, POne), '(Length, POne)] (Unit Newton) f
 newton = one
 
 -- |One joule.
-joule :: (Fractional f) => Value f Energy (Unit Joule)
+joule :: (Fractional f) => Value Energy (Unit Joule) f
 joule = one
 
 -- |One eV.
-eV :: (Fractional f) => Value f Energy (Unit Ev)
+eV :: (Fractional f) => Value Energy (Unit Ev) f
 eV = one
 
 -- |One kwh.
-kwh :: (Fractional f) => Value f Energy '[ '(Kilo Watt, POne), '(Hour, POne) ]
+kwh :: (Fractional f) => Value Energy '[ '(Kilo Watt, POne), '(Hour, POne) ] f
 kwh = one
 
 -- |One watt.
-watt :: (Fractional f) => Value f Power (Unit Watt)
+watt :: (Fractional f) => Value Power (Unit Watt) f
 watt = one
 
 -- |One pascal.
-pascal :: (Fractional f) => Value f Pressure (Unit Pascal)
+pascal :: (Fractional f) => Value Pressure (Unit Pascal) f
 pascal = one
 
 -- |One bar.
-bar :: (Fractional f) => Value f Pressure (Unit Bar)
+bar :: (Fractional f) => Value Pressure (Unit Bar) f
 bar = one
 
 -- |One mmHg.
-mmHg :: (Fractional f) => Value f Pressure (Unit MmHg)
+mmHg :: (Fractional f) => Value Pressure (Unit MmHg) f
 mmHg = one
 
 -- |One coulomb.
-coulomb :: (Fractional f) => Value f Charge (Unit Coulomb)
+coulomb :: (Fractional f) => Value Charge (Unit Coulomb) f
 coulomb = one
 
 -- |One volt.
-volt :: (Fractional f) => Value f Potential (Unit Volt)
+volt :: (Fractional f) => Value Potential (Unit Volt) f
 volt = one
 
 -- |One farad.
-farad :: (Fractional f) => Value f Capacitance (Unit Farad)
+farad :: (Fractional f) => Value Capacitance (Unit Farad) f
 farad = one
 
 -- |One ohm.
-ohm :: (Fractional f) => Value f Resistance (Unit Ohm)
+ohm :: (Fractional f) => Value Resistance (Unit Ohm) f
 ohm = one
 
 -- |One siemens.
-siemens :: (Fractional f) => Value f Conductance (Unit Siemens)
+siemens :: (Fractional f) => Value Conductance (Unit Siemens) f
 siemens = one
 
 -- |One weber.
-weber :: (Fractional f) => Value f Flux (Unit Weber)
+weber :: (Fractional f) => Value Flux (Unit Weber) f
 weber = one
 
 -- |One tesla.
-tesla :: (Fractional f) => Value f FluxDensity (Unit Tesla)
+tesla :: (Fractional f) => Value FluxDensity (Unit Tesla) f
 tesla = one
 
 -- |One henry.
-henry :: (Fractional f) => Value f Inductance (Unit Henry)
+henry :: (Fractional f) => Value Inductance (Unit Henry) f
 henry = one

File src/UnitTyped/SI/Derived/Count.hs

 --
 
 -- |One percent (%).
-percent :: (Fractional f) => Value f '[] (Unit Percentage)
+percent :: (Fractional f) => Value '[] (Unit Percentage) f
 percent = one
 
 -- |One per mille (‰).
-permil :: (Fractional f) => Value f '[] (Unit Permil)
+permil :: (Fractional f) => Value '[] (Unit Permil) f
 permil = one
 
 -- |One part per million (ppm).
-ppm :: (Fractional f) => Value f '[] (Unit Ppm)
+ppm :: (Fractional f) => Value '[] (Unit Ppm) f
 ppm = one
 
 -- |One part per billion (ppb).
-ppb :: (Fractional f) => Value f '[] (Unit Ppb)
+ppb :: (Fractional f) => Value '[] (Unit Ppb) f
 ppb = one
 
 -- |One part per trillion (ppt).
-ppt :: (Fractional f) => Value f '[] (Unit Ppt)
+ppt :: (Fractional f) => Value '[] (Unit Ppt) f
 ppt = one
 
 -- |One rad (rad).
-rad :: (Fractional f) => Value f '[] (Unit Radian)
+rad :: (Fractional f) => Value '[] (Unit Radian) f
 rad = one
 
 -- |One degree (˚).
-deg :: (Fractional f) => Value f '[] (Unit Degree)
+deg :: (Fractional f) => Value '[] (Unit Degree) f
 deg = one

File src/UnitTyped/SI/Derived/Length.hs

 --
 
 -- |One mile (mile).
-mile :: (Fractional f) => Value f LengthDimension (Unit Mile)
+mile :: (Fractional f) => Value LengthDimension (Unit Mile) f
 mile = one
 
 -- |One inch (in).
-inch :: (Fractional f) => Value f LengthDimension (Unit Inch)
+inch :: (Fractional f) => Value LengthDimension (Unit Inch) f
 inch = one
 
 -- |One yard (yd).
-yard :: (Fractional f) => Value f LengthDimension (Unit Yard)
+yard :: (Fractional f) => Value LengthDimension (Unit Yard) f
 yard = one
 
 -- |One foot (ft).
-foot :: (Fractional f) => Value f LengthDimension (Unit Foot)
+foot :: (Fractional f) => Value LengthDimension (Unit Foot) f
 foot = one
 
-ångström, angstrom :: (Fractional f) => Value f LengthDimension (Unit Ångström)
+ångström, angstrom :: (Fractional f) => Value LengthDimension (Unit Ångström) f
 -- |One ångström (Å).
 ångström = one
 -- |One ångström, for those with bad UTF-8 support (Å).
 angstrom = one
 
 -- |One nautical mile (M).
-nautical_mile :: (Fractional f) => Value f LengthDimension (Unit NauticalMile)
+nautical_mile :: (Fractional f) => Value LengthDimension (Unit NauticalMile) f
 nautical_mile = one
 
 --
 
 -- |One barn (b).
-barn :: (Fractional f) => Value f AreaUnit (Unit Barn)
+barn :: (Fractional f) => Value AreaUnit (Unit Barn) f
 barn = one
 
 --
 
 -- |One liter (L).
-liter :: (Fractional f) => Value f VolumeUnit (Unit Liter)
+liter :: (Fractional f) => Value VolumeUnit (Unit Liter) f
 liter = one
 
 -- |One gallon (gallon).
-gallon :: (Fractional f) => Value f VolumeUnit (Unit Gallon)
+gallon :: (Fractional f) => Value VolumeUnit (Unit Gallon) f
 gallon = one
 
 -- |One fluid ounce (fl oz).
-fluid_ounce :: (Fractional f) => Value f VolumeUnit (Unit FluidOunce)
+fluid_ounce :: (Fractional f) => Value VolumeUnit (Unit FluidOunce) f
 fluid_ounce = one

File src/UnitTyped/SI/Derived/Mass.hs

 --
 
 -- |One pound (lb).
-pound :: (Fractional f) => Value f MassDimension (Unit Pound)
+pound :: (Fractional f) => Value MassDimension (Unit Pound) f
 pound = one

File src/UnitTyped/SI/Derived/Time.hs

 --
 
 -- |One minute (min.).
-minute :: (Fractional f) => Value f TimeDimension (Unit Minute)
+minute :: (Fractional f) => Value TimeDimension (Unit Minute) f
 minute = one
 
 -- |One hour (h).
-hour :: (Fractional f) => Value f TimeDimension (Unit Hour)
+hour :: (Fractional f) => Value TimeDimension (Unit Hour) f
 hour = one
 
 -- |One day (day).
-day :: (Fractional f) => Value f TimeDimension (Unit Day)
+day :: (Fractional f) => Value TimeDimension (Unit Day) f
 day = one
 
 -- |One year (yr).
-year :: (Fractional f) => Value f TimeDimension (Unit Year)
+year :: (Fractional f) => Value TimeDimension (Unit Year) f
 year = one
 
 -- |One Julian year (a).
-julian_year :: (Fractional f) => Value f TimeDimension (Unit JulianYear)
+julian_year :: (Fractional f) => Value TimeDimension (Unit JulianYear) f
 julian_year = one
 
 -- |One month (month).
-month :: (Fractional f) => Value f TimeDimension (Unit Month)
+month :: (Fractional f) => Value TimeDimension (Unit Month) f
 month = one
 
 -- |One herz (Hz).
-hertz :: (Fractional f) => Value f '[ '(Time, NOne) ] (Unit Hertz)
+hertz :: (Fractional f) => Value '[ '(Time, NOne) ] (Unit Hertz) f
 hertz = one
 
 --
 -- Interaction with Data.Time
 
 -- |Convert a 'DT.DiffTime' into a value in seconds.
-fromDiffTime :: (Fractional f) => DT.DiffTime -> Value f TimeDimension (Unit Second)
+fromDiffTime :: (Fractional f) => DT.DiffTime -> Value TimeDimension (Unit Second) f
 fromDiffTime = mkVal . fromRational . toRational
 
 -- |Convert a 'DTC.NominalDiffTime' into a value in seconds.
-fromNominalDiffTime :: (Fractional f) => DTC.NominalDiffTime -> Value f TimeDimension (Unit Second)
+fromNominalDiffTime :: (Fractional f) => DTC.NominalDiffTime -> Value TimeDimension (Unit Second) f
 fromNominalDiffTime = mkVal . fromRational . toRational
 
 -- |Convert the number of seconds since a given 'DTC.UTCTime' into a value in seconds.
-since :: (Fractional f) => DTC.UTCTime -> IO (Value f TimeDimension (Unit Second))
+since :: (Fractional f) => DTC.UTCTime -> IO (Value TimeDimension (Unit Second) f)
 since time = do { t <- DTC.getCurrentTime
 		        ; return (fromNominalDiffTime (DTC.diffUTCTime t time) `as` second)
 		        }
 
 -- |Calculate the number of seconds since a given date and\/or time, parsed according to the first argument.
-since_str :: (Fractional f) => String -> String -> IO (Value f TimeDimension (Unit Second))
+since_str :: (Fractional f) => String -> String -> IO (Value TimeDimension (Unit Second) f)
 since_str fmt str = since (DTF.readTime SL.defaultTimeLocale fmt str)

File src/UnitTyped/SI/Meta.hs

 ----
 
 -- |Take a unit and return one deca(unit).
-deca :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Deca b))
+deca :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Deca b)) f
 deca (Value x) = (Value x)
 
 -- |Take a unit and return one hecto(unit).
-hecto :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Hecto b))
+hecto :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Hecto b)) f
 hecto (Value x) = (Value x)
 
 -- |Take a unit and return one kilo(unit).
-kilo :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Kilo b))
+kilo :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Kilo b)) f
 kilo (Value x) = (Value x)
 
 -- |Take a unit and return one mega(unit).
-mega :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Mega b))
+mega :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Mega b)) f
 mega (Value x) = (Value x)
 
 -- |Take a unit and return one giga(unit).
-giga :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Giga b))
+giga :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Giga b)) f
 giga (Value x) = (Value x)
 
 -- |Take a unit and return one tera(unit).
-tera :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Tera b))
+tera :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Tera b)) f
 tera (Value x) = (Value x)
 
 -- |Take a unit and return one peta(unit).
-peta :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Peta b))
+peta :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Peta b)) f
 peta (Value x) = (Value x)
 
 -- |Take a unit and return one exa(unit).
-exa :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Exa b))
+exa :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Exa b)) f
 exa (Value x) = (Value x)
 
 -- |Take a unit and return one zetta(unit).
-zetta :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Zetta b))
+zetta :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Zetta b)) f
 zetta (Value x) = (Value x)
 
 -- |Take a unit and return one yotta(unit).
-yotta :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Yotta b))
+yotta :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Yotta b)) f
 yotta (Value x) = (Value x)
 
 -- |Take a unit and return one deci(unit).
-deci :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Deci b))
+deci :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Deci b)) f
 deci (Value x) = (Value x)
 
 -- |Take a unit and return one centi(unit).
-centi :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Centi b))
+centi :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Centi b)) f
 centi (Value x) = (Value x)
 
 -- |Take a unit and return one mili(unit).
-mili :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Mili b))
+mili :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Mili b)) f
 mili (Value x) = (Value x)
 
 -- |Take a unit and return one micro(unit).
-micro :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Micro b))
+micro :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Micro b)) f
 micro (Value x) = (Value x)
 
 -- |Take a unit and return one nano(unit).
-nano :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Nano b))
+nano :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Nano b)) f
 nano (Value x) = (Value x)
 
 -- |Take a unit and return one pico(unit).
-pico :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Pico b))
+pico :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Pico b)) f
 pico (Value x) = (Value x)
 
 -- |Take a unit and return one femto(unit).
-femto :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Femto b))
+femto :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Femto b)) f
 femto (Value x) = (Value x)
 
 -- |Take a unit and return one atto(unit).
-atto :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Atto b))
+atto :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Atto b)) f
 atto (Value x) = (Value x)
 
 -- |Take a unit and return one zepto(unit).
-zepto :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Zepto b))
+zepto :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Zepto b)) f
 zepto (Value x) = (Value x)
 
 -- |Take a unit and return one yocto(unit).
-yocto :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Yocto b))
+yocto :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Yocto b)) f
 yocto (Value x) = (Value x)
 
 --
 
 -- |Take a unit and return one kibi(unit).
-kibi :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Kibi b))
+kibi :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Kibi b)) f
 kibi (Value x) = (Value x)
 
 -- |Take a unit and return one mebi(unit).
-mebi :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Mebi b))
+mebi :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Mebi b)) f
 mebi (Value x) = (Value x)
 
 -- |Take a unit and return one gibi(unit).
-gibi :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Gibi b))
+gibi :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Gibi b)) f
 gibi (Value x) = (Value x)
 
 -- |Take a unit and return one tebi(unit).
-tebi :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Tebi b))
+tebi :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Tebi b)) f
 tebi (Value x) = (Value x)
 
 -- |Take a unit and return one pebi(unit).
-pebi :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Pebi b))
+pebi :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Pebi b)) f
 pebi (Value x) = (Value x)
 
 -- |Take a unit and return one exbi(unit).
-exbi :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Exbi b))
+exbi :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Exbi b)) f
 exbi (Value x) = (Value x)
 
 -- |Take a unit and return one zebi(unit).
-zebi :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Zebi b))
+zebi :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Zebi b)) f
 zebi (Value x) = (Value x)
 
 -- |Take a unit and return one yobi(unit).
-yobi :: (Convertible a b, Fractional f) => Value f a (Unit b) -> Value f a (Unit (Yobi b))
+yobi :: (Convertible a b, Fractional f) => Value a (Unit b) f -> Value a (Unit (Yobi b)) f
 yobi (Value x) = (Value x)

File src/UnitTyped/SI/Show.hs

 -- |Start a chain of units. For example:
 --
 -- > format_end second $ format minute $ format_start hour x
-format_start :: (Convertible' a b, Convertible' c d, MapEq a c 'True) => Value Rational c d -> Value Rational a b -> (String, Value Rational c d)
+format_start :: (Convertible' a b, Convertible' c d, MapEq a c 'True) => Value c d Rational -> Value a b Rational -> (String, Value c d Rational)
 format_start u v = format u ("", (NP.abs v) `as` u)
 
 -- |Add a unit in between 'format_start' and 'format_end'.
-format :: (Convertible' a b, Convertible' a d) => Value Rational a d -> (String, Value Rational a b) -> (String, Value Rational a d)
+format :: (Convertible' a b, Convertible' a d) => Value a d Rational -> (String, Value a b Rational) -> (String, Value a d Rational)
 format u (s, v) = let
 					  fl_v = NP.floor (coerce v u)
 					  str = (show $ numerator $ val $ fl_v) ++ " " ++ (showunit' $ proxy' u)
 			      in (s ++ (if val fl_v == 0 then "" else (if not $ null s then ", " else "") ++ str), NP.diff $ coerce v u)
 
 -- |End the chain of formatters.
-format_end :: (Convertible' a b, Convertible' a d) => Value Rational a d -> (String, Value Rational a b) -> String
+format_end :: (Convertible' a b, Convertible' a d) => Value a d Rational -> (String, Value a b Rational) -> String
 format_end u (s, v) = (s ++ (if val v == 0 then "" else ((if not $ null s then ", " else "") ++ (show $ fromRational $ val (coerce v u)) ++ " " ++ (showunit' $ proxy' u))))
 
 -- |Show a time range as years, days, hours, minutes, seconds and miliseconds.
-time_str :: (Convertible' a b, MapEq a TimeDimension 'True) => Value Rational a b -> String
+time_str :: (Convertible' a b, MapEq a TimeDimension 'True) => Value a b Rational -> String
 time_str = format_end (mili second) . format second . format minute . format hour . format day . format_start year
 
 -- |Show a unit with all possible SI-prefixes.
 --
 -- >>> meta_str meter (c |*| 1 *| year)
 -- "9 Pm, 460 Tm, 536 Gm, 207 Mm, 68 km, 16 m"
-meta_str :: (Convertible' a b, Convertible c d, MapEq a c 'True) => Value Rational c (Unit d) -> Value Rational a b -> String
+meta_str :: (Convertible' a b, Convertible c d, MapEq a c 'True) => Value c (Unit d) Rational -> Value a b Rational -> String
 meta_str unit v = format_end (yocto unit) $ format (zepto unit) $ format (atto unit) $ format (femto unit)
 					$ format (pico unit) $ format (nano unit) $ format (micro unit) $ format (mili unit)
 					$ format unit $ format (kilo unit) $ format (mega unit) $ format (giga unit)