diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2006-2007, Bjorn Buckwalter.
+Copyright (c) 2006-2008, Bjorn Buckwalter.
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/Numeric/NumType.lhs b/Numeric/NumType.lhs
--- a/Numeric/NumType.lhs
+++ b/Numeric/NumType.lhs
@@ -42,6 +42,18 @@
 >            , FlexibleInstances 
 > #-}
 
+> {- |
+>    Copyright  : Copyright (C) 2006-2008 Bjorn Buckwalter
+>    License    : BSD3
+>
+>    Maintainer : bjorn.buckwalter@gmail.com
+>    Stability  : Stable
+>    Portability: GHC only?
+> 
+> Please refer to the literate Haskell code for documentation of both API
+> and implementation.
+> -}
+
 > module Numeric.NumType 
 >   -- Basic classes (exported versions).
 >   ( NumType, PosType, NegType, NonZero
@@ -159,8 +171,8 @@
 For convenience we create show instances for the defined NumTypes.
 
 > instance Show Zero where show _ = "NumType 0"
-> instance (PosTypeI n) => Show (Pos n) where show x = "NumType " ++ show (toNum x)
-> instance (NegTypeI n) => Show (Neg n) where show x = "NumType " ++ show (toNum x)
+> instance (PosTypeI n) => Show (Pos n) where show x = "NumType " ++ show (toNum x :: Integer)
+> instance (NegTypeI n) => Show (Neg n) where show x = "NumType " ++ show (toNum x :: Integer)
 
  
 = Negation, incrementing and decrementing =
@@ -361,15 +373,25 @@
 
 > zero :: Zero  -- ~ hZero
 > zero = undefined
+> pos1 :: Pos1
 > pos1 = incr zero
+> pos2 :: Pos2
 > pos2 = incr pos1
+> pos3 :: Pos3
 > pos3 = incr pos2
+> pos4 :: Pos4
 > pos4 = incr pos3
+> pos5 :: Pos5
 > pos5 = incr pos4
+> neg1 :: Neg1
 > neg1 = decr zero
+> neg2 :: Neg2
 > neg2 = decr neg1
+> neg3 :: Neg3
 > neg3 = decr neg2
+> neg4 :: Neg4
 > neg4 = decr neg3
+> neg5 :: Neg5
 > neg5 = decr neg4
 
 
diff --git a/Numeric/Units/Dimensional.lhs b/Numeric/Units/Dimensional.lhs
--- a/Numeric/Units/Dimensional.lhs
+++ b/Numeric/Units/Dimensional.lhs
@@ -56,6 +56,18 @@
 >            , FlexibleContexts
 > #-}
 
+> {- |
+>    Copyright  : Copyright (C) 2006-2008 Bjorn Buckwalter
+>    License    : BSD3
+>
+>    Maintainer : bjorn.buckwalter@gmail.com
+>    Stability  : Stable
+>    Portability: GHC only?
+> 
+> Please refer to the literate Haskell code for documentation of both API
+> and implementation.
+> -}
+
 > module Numeric.Units.Dimensional 
 >       -- TODO discriminate exports, in particular Variants and Dims.
 >   where
@@ -63,7 +75,7 @@
 > import Prelude 
 >   ( Show, Eq, Ord, Num, Fractional, Floating, RealFloat, Functor, fmap
 >   , (.), flip, show, (++), undefined, otherwise, (==), String, unwords
->   , map, foldr
+>   , map, foldr, null, Integer
 >   )
 > import qualified Prelude 
 > import Data.List (genericLength)
@@ -71,7 +83,6 @@
 > import Numeric.NumType 
 >   ( NumType, NonZero, PosType, Zero, toNum, Sum
 >   , Pos1, Pos2, pos2, Pos3, pos3
->   , neg3, zero -- Only for playing around.
 >   )
 > import qualified Numeric.NumType as N (Mul, Div)
 
@@ -296,7 +307,7 @@
 
 > (^) :: (Fractional a, Pow d n d')
 >     => Dimensional v d a -> n -> Dimensional v d' a
-> Dimensional x ^ n = Dimensional (x Prelude.^^ toNum n)
+> Dimensional x ^ n = Dimensional (x Prelude.^^ (toNum n :: Integer))
 
 In the unlikely case someone needs to use this library with
 non-fractional numbers we provide the alternative power operator
@@ -304,7 +315,7 @@
 
 > (^+) :: (Num a, PosType n, Pow d n d')
 >      => Dimensional v d a -> n -> Dimensional v d' a
-> Dimensional x ^+ n = Dimensional (x Prelude.^ toNum n)
+> Dimensional x ^+ n = Dimensional (x Prelude.^ (toNum n :: Integer))
 
 A special case is that dimensionless quantities are not restricted
 to integer exponents. This is accommodated by the '**' operator
@@ -451,7 +462,8 @@
 even a requirement.
 
 > instance forall d a. (Show d, Show a) => Show (Quantity d a) where
->   show (Dimensional x) = show x ++ " " ++ show (undefined :: d)
+>   show (Dimensional x) = show x ++ if (null unit) then "" else " " ++ unit
+>       where unit = show (undefined :: d)
 
 The above implementation of 'show' relies on the dimension 'd' being an
 instance of 'Show'. The "normalized" unit of the quantity can be inferred
@@ -486,7 +498,7 @@
 >   | x == 0    = Nothing
 >   | x == 1    = Just u
 >   | otherwise = Just (u ++ "^" ++ show x)
->   where x = toNum n
+>   where x = toNum n :: Integer
 
 
 = The 'prefix' function =
diff --git a/Numeric/Units/Dimensional/CGS.lhs b/Numeric/Units/Dimensional/CGS.lhs
--- a/Numeric/Units/Dimensional/CGS.lhs
+++ b/Numeric/Units/Dimensional/CGS.lhs
@@ -51,16 +51,29 @@
 >            , FlexibleContexts
 > #-}
 
+> {- |
+>    Copyright  : Copyright (C) 2006-2008 Bjorn Buckwalter
+>    License    : BSD3
+>
+>    Maintainer : bjorn.buckwalter@gmail.com
+>    Stability  : Experimental
+>    Portability: GHC only?
+> 
+> Please refer to the literate Haskell code for documentation of both API
+> and implementation.
+> -}
+
 > module Numeric.Units.Dimensional.CGS where
 
-> import Prelude ( undefined, Num, Fractional, Floating, Show, recip, Double )
+> import Prelude
+>   ( undefined, Num, Fractional, Floating, Show, recip, Double, unwords, (.) )
 > import qualified Prelude
 > import Numeric.Units.Dimensional hiding ( DLength, DMass, DTime, DElectricCurrent )
 > import Numeric.Units.Dimensional.Quantities as SIQ
 > import qualified Numeric.Units.Dimensional.SIUnits as SI
 > import qualified Numeric.NumType as N
-> import Numeric.NumType ( Neg2, Neg1, Zero, Pos, Pos1, Pos2, Pos3, NumType )
-> import Numeric.NumType ( neg2, neg1, zero, pos1, pos2, pos3 )
+> import Numeric.NumType ( Neg2, Neg1, Zero, Pos1, Pos2, Pos3, NumType )
+> import Numeric.NumType ( neg2, pos2, pos3 )
 > import Data.Maybe (catMaybes)
  
 
@@ -245,7 +258,7 @@
 >     , NumType mh
 >     , NumType t
 >     ) => Show (CGSDim lh mh t) where
->     show _ = (Prelude.unwords Prelude.. catMaybes)
+>     show _ = (unwords . catMaybes)
 >              [ dimUnit "sqrt(cm)" (undefined :: lh)
 >              , dimUnit "sqrt(g)"  (undefined :: mh)
 >              , dimUnit "s"        (undefined :: t)
diff --git a/Numeric/Units/Dimensional/Extensible.lhs b/Numeric/Units/Dimensional/Extensible.lhs
--- a/Numeric/Units/Dimensional/Extensible.lhs
+++ b/Numeric/Units/Dimensional/Extensible.lhs
@@ -34,6 +34,18 @@
 >            , FlexibleInstances
 > #-}
 
+> {- |
+>    Copyright  : Copyright (C) 2006-2008 Bjorn Buckwalter
+>    License    : BSD3
+>
+>    Maintainer : bjorn.buckwalter@gmail.com
+>    Stability  : Experimental
+>    Portability: GHC only?
+> 
+> Please refer to the literate Haskell code for documentation of both API
+> and implementation.
+> -}
+
 > module Numeric.Units.Dimensional.Extensible ( DExt, showDExt ) where
 
 > import Numeric.Units.Dimensional ( Dim, Mul, Div, Pow, Root, dimUnit )
@@ -86,8 +98,9 @@
 > showDExt :: forall a n d. (NumType n, Show d) => String -> DExt a n d -> String
 > showDExt u _ = showHelp (dimUnit u (undefined :: n)) (show (undefined :: d))
 >        where
->            showHelp Nothing  s  = s
->            showHelp (Just s) s' = s ++ " " ++ s'
+>            showHelp Nothing   s  = s
+>            showHelp (Just u') "" = u'
+>            showHelp (Just u') s  = u' ++ " " ++ s
 
 Using this helper function defining 'Show' instances for the dimensions
 with extent in apples and oranges is simple.
diff --git a/Numeric/Units/Dimensional/ExtensibleTest.lhs b/Numeric/Units/Dimensional/ExtensibleTest.lhs
new file mode 100644
--- /dev/null
+++ b/Numeric/Units/Dimensional/ExtensibleTest.lhs
@@ -0,0 +1,91 @@
+> {-# LANGUAGE EmptyDataDecls, FlexibleInstances #-}
+
+> module Numeric.Units.Dimensional.ExtensibleTest where
+
+> import Numeric.Units.Dimensional.Prelude
+> import Numeric.Units.Dimensional.Extensible
+> import Numeric.Units.Dimensional ( Dimensional (Dimensional), dimUnit )
+> import Numeric.NumType ( NumType, Zero, Pos1, Neg1 )
+> import Test.HUnit
+> import qualified Prelude
+
+
+= Setting up the problem domain =
+
+For testing we will use apples, oranges and peaches. We define the
+type tags and show instances for each.
+
+> data TApples  -- Type tag.
+> type DApples  = DExt TApples Pos1 DOne
+> type Apples   = Quantity DApples
+
+> data TOranges -- Type tag.
+> type DOranges = DExt TApples Zero (DExt TOranges Pos1 DOne)
+> type Oranges  = Quantity DOranges
+
+> data TPeaches -- Type tag.
+> type DPeaches = DExt TApples Zero (DExt TOranges Zero (DExt TPeaches Pos1 DOne))
+> type Peaches  = Quantity DPeaches
+
+Define show instances.
+
+> instance (NumType n, Show d) => Show (DExt TApples n d) where
+>   show = showDExt "apple" 
+
+> instance (NumType n, Show d) => Show (DExt TOranges n d) where
+>   show = showDExt "orange" 
+
+> instance (NumType n, Show d) => Show (DExt TPeaches n d) where
+>   show = showDExt "peaches" 
+
+Finally the base units.
+
+> apple  :: Num a => Unit DApples a
+> apple  = Dimensional 1
+> orange :: Num a => Unit DOranges a
+> orange = Dimensional 1
+> peach  :: Num a => Unit DPeaches a
+> peach  = Dimensional 1
+
+
+= Test values =
+
+> a = 1 *~ apple
+> o = 2 *~ orange
+> m = 3 *~ meter
+> p = 4 *~ peach
+
+
+= Stuff we expect to compile =
+
+> f = a / o * p
+> f' = a * o
+> f'' = m / a
+
+> foo1 :: Quantity (DExt TApples Pos1 (DExt TOranges Neg1 (DLength))) Double
+> foo1 = a / o * m
+
+> foo2 :: Double
+> foo2 = a * m / a /~ meter
+
+> foo3 :: Length Double
+> foo3 = a * m / a + m
+
+
+Finally a HUnit test case.
+
+> testShow = TestLabel "Test 'Show' instance" $ TestList
+>   [ TestCase $ show (1 *~ apple) @?= "1 apple"
+>   , TestCase $ show (2 *~ orange) @?= "2 orange"
+>   , TestCase $ show (2.0 *~ (apple / second)) @?= "2.0 apple s^-1"
+>   , TestCase $ show (2.0 *~ (meter ^ pos2 / peach ^ pos2)) @?= "2.0 peaches^-2 m^2"
+>   , TestCase $ show (2.0 *~ (apple ^ pos2 / peach ^ pos2)) @?= "2.0 apple^2 peaches^-2"
+>   , TestCase $ show (undefined :: DApples) @?= "apple"
+>   ]
+
+Main function.
+
+> main = do 
+>   putStrLn "If I compiled I'm mostly OK!"
+>   runTestTT $ TestList [testShow]
+
diff --git a/Numeric/Units/Dimensional/NonSI.lhs b/Numeric/Units/Dimensional/NonSI.lhs
--- a/Numeric/Units/Dimensional/NonSI.lhs
+++ b/Numeric/Units/Dimensional/NonSI.lhs
@@ -12,6 +12,18 @@
 Any chapters, sections or tables referenced are from [1] unless
 otherwise specified.
 
+> {- |
+>    Copyright  : Copyright (C) 2006-2008 Bjorn Buckwalter
+>    License    : BSD3
+>
+>    Maintainer : bjorn.buckwalter@gmail.com
+>    Stability  : Stable
+>    Portability: GHC only?
+> 
+> Please refer to the literate Haskell code for documentation of both API
+> and implementation.
+> -}
+
 > module Numeric.Units.Dimensional.NonSI where
 
 > import Numeric.Units.Dimensional.Prelude
@@ -64,6 +76,10 @@
 
 Other (non inch-pound) units.
 
+> yard, mile, nauticalMile :: (Fractional a) => Unit DLength a
+> yard = prefix 3 foot
+> mile = prefix 1760 yard
+> nauticalMile = prefix 1852 meter
 > revolution :: (Floating a) => Unit DOne a
 > revolution = prefix 360 degree
 > bar :: (Fractional a) => Unit DPressure a
diff --git a/Numeric/Units/Dimensional/Prelude.hs b/Numeric/Units/Dimensional/Prelude.hs
--- a/Numeric/Units/Dimensional/Prelude.hs
+++ b/Numeric/Units/Dimensional/Prelude.hs
@@ -16,7 +16,7 @@
 
 import Numeric.NumType 
     ( neg5, neg4, neg3, neg2, neg1, zero, pos1, pos2, pos3, pos4, pos5
-    ) -- ^Used in exponents.
+    )  -- Used in exponents.
 
 import Prelude hiding
     ( (+), (-), (*), (/), (^), (**)
@@ -24,4 +24,4 @@
     , sin, cos, tan, asin, acos, atan, atan2
     , sinh, cosh, tanh, asinh, acosh, atanh
     , sum
-    ) -- ^Hide definitions overridden by 'Numeric.Dimensional'.
+    )  -- Hide definitions overridden by 'Numeric.Dimensional'.
diff --git a/Numeric/Units/Dimensional/Quantities.lhs b/Numeric/Units/Dimensional/Quantities.lhs
--- a/Numeric/Units/Dimensional/Quantities.lhs
+++ b/Numeric/Units/Dimensional/Quantities.lhs
@@ -15,6 +15,18 @@
 is defined. If there are several quantity types with the same
 dimensionality type synonyms are provided for each quantity type.
 
+> {- |
+>    Copyright  : Copyright (C) 2006-2008 Bjorn Buckwalter
+>    License    : BSD3
+>
+>    Maintainer : bjorn.buckwalter@gmail.com
+>    Stability  : Stable
+>    Portability: GHC only?
+> 
+> Please refer to the literate Haskell code for documentation of both API
+> and implementation.
+> -}
+
 > module Numeric.Units.Dimensional.Quantities where
 
 > import Numeric.Units.Dimensional 
@@ -286,6 +298,9 @@
 
 > type DMassFlow = Dim Zero Pos1 Neg1 Zero Zero Zero Zero
 > type MassFlow  = Quantity DMassFlow
+
+> type DGravitationalParameter = Dim Pos3 Zero Neg2 Zero Zero Zero Zero
+> type GravitationalParameter = Quantity DGravitationalParameter
 
 For these we don't bother defining new type synonyms for dimensionalities.
 Is this rational?
diff --git a/Numeric/Units/Dimensional/QuantitiesTest.hs b/Numeric/Units/Dimensional/QuantitiesTest.hs
new file mode 100644
--- /dev/null
+++ b/Numeric/Units/Dimensional/QuantitiesTest.hs
@@ -0,0 +1,88 @@
+module Numeric.Units.Dimensional.QuantitiesTest where
+
+import Numeric.Units.Dimensional.Prelude
+import qualified Prelude
+
+-- These definitions simply verify that the type synonyms are
+-- consistent with the appropriate units from table 2. If the
+-- definitions compile the type synonyms are good.
+
+x1 :: Area Double
+x1 = 1 *~ meter ^ pos2
+x2 :: Volume Double
+x2 = 1 *~ meter ^ pos3
+x3 :: Velocity Double
+x3 = 1 *~ (meter / second)
+x4 :: Acceleration Double
+x4 = 1 *~ (meter / second ^ pos2)
+x5 :: WaveNumber Double
+x5 = 1 *~ meter ^ neg1
+x6 :: Density Double
+x6 = 1 *~ (kilo gram / meter ^ pos3)
+x7 :: SpecificVolume Double
+x7 = 1 *~ (meter ^ pos3 / kilo gram)
+x8 :: CurrentDensity Double
+x8 = 1 *~ (ampere / meter ^ pos2)
+x9 :: MagneticFieldStrength Double
+x9 = 1 *~ (ampere / meter)
+x10 :: Concentration Double
+x10 = 1 *~ (mole / meter ^ pos3)
+x11 :: Luminance Double
+x11 = 1 *~ (candela / meter ^ pos2)
+
+-- Tables 3a and 3b are implicitely tested by the corresponding
+-- unit definitions.
+
+-- Verification of table 4. If the definitions compile the type
+-- synonyms are good.
+
+y1 :: AngularVelocity Double
+y1 = 1 *~ (radian / second)
+y2 :: AngularAcceleration Double
+y2 = 1 *~ (radian / second ^ pos2)
+y3 :: DynamicViscosity Double
+y3 = 1 *~ (pascal * second)
+y4 :: MomentOfForce Double
+y4 = 1 *~ (newton * meter)
+y5 :: SurfaceTension Double
+y5 = 1 *~ (newton / meter)
+y6 :: HeatFluxDensity Double
+y6 = 1 *~ (watt / meter ^ pos2)
+y7 :: RadiantIntensity Double
+y7 = 1 *~ (watt / steradian)
+y8 :: Radiance Double
+y8 = 1 *~ (watt / (meter ^ pos2 * steradian))
+y9 :: HeatCapacity Double
+y9 = 1 *~ (joule / kelvin)
+y10 :: SpecificHeatCapacity Double
+y10 = 1 *~ (joule / (kilo gram * kelvin))
+y11 :: ThermalConductivity Double
+y11 = 1 *~ (watt / (meter * kelvin))
+y12 :: EnergyDensity Double
+y12 = 1 *~ (joule / meter ^ pos3)
+y13 :: ElectricFieldStrength Double
+y13 = 1 *~ (volt / meter)
+y14 :: ElectricChargeDensity Double
+y14 = 1 *~ (coulomb / meter ^ pos3)
+y15 :: ElectricFluxDensity Double
+y15 = 1 *~ (coulomb / meter ^ pos2)
+y16 :: Permittivity Double
+y16 = 1 *~ (farad / meter)
+y17 :: Permeability Double
+y17 = 1 *~ (henry / meter)
+y18 :: MolarEnergy Double
+y18 = 1 *~ (joule / mole)
+y19 :: MolarEntropy Double
+y19 = 1 *~ (joule / (mole * kelvin))
+y20 :: Exposure Double
+y20 = 1 *~ (coulomb / kilo gram)
+y21 :: AbsorbedDoseRate Double
+y21 = 1 *~ (gray / second)
+
+-- Other quantitites.
+mu :: GravitationalParameter Double
+mu = 398600.4418 *~ (kilo meter ^ pos3 / second ^ pos2)
+
+-- Dummy main function.
+main = Prelude.putStrLn "If I compiled I'm OK!"
+
diff --git a/Numeric/Units/Dimensional/SIUnits.lhs b/Numeric/Units/Dimensional/SIUnits.lhs
--- a/Numeric/Units/Dimensional/SIUnits.lhs
+++ b/Numeric/Units/Dimensional/SIUnits.lhs
@@ -10,14 +10,23 @@
 accepted for use with the SI. Any chapters, sections or tables
 referenced are from [1] unless otherwise specified.
 
+> {- |
+>    Copyright  : Copyright (C) 2006-2008 Bjorn Buckwalter
+>    License    : BSD3
+>
+>    Maintainer : bjorn.buckwalter@gmail.com
+>    Stability  : Stable
+>    Portability: GHC only?
+> 
+> Please refer to the literate Haskell code for documentation of both API
+> and implementation.
+> -}
+
 > module Numeric.Units.Dimensional.SIUnits where
 
 > import Numeric.Units.Dimensional
 > import Numeric.Units.Dimensional.Quantities
-> import Numeric.NumType 
->   ( Neg3, Neg2, Neg1, Zero, Pos1, Pos2, Pos3, Pos4
->   , neg3, neg2, neg1, pos1, pos2, pos3
->   )
+> import Numeric.NumType ( neg1, neg2, pos2, pos3 )
 > import Data.Time.Clock (DiffTime)
 > import Prelude ( (.), Num, Real (toRational), Fractional (fromRational), Floating, recip )
 > import qualified Prelude
diff --git a/Numeric/Units/Dimensional/Test.hs b/Numeric/Units/Dimensional/Test.hs
new file mode 100644
--- /dev/null
+++ b/Numeric/Units/Dimensional/Test.hs
@@ -0,0 +1,35 @@
+{-# LANGUAGE NoMonomorphismRestriction #-}
+
+module Numeric.Units.Dimensional.Test where
+
+import Numeric.Units.Dimensional.Prelude
+import qualified Prelude
+import Test.HUnit
+
+testPower = TestLabel "Power test" $ TestList
+    [ TestCase $ (9 *~ one) @=? (3 *~ one) ^ pos2
+    , TestCase $ (1 *~ one) @=? (12.1231 *~ one) ^ zero
+    , TestCase $ (0.25 *~ one) @=? (2 *~ one) ^ neg2
+    ]
+
+testDimensionless = TestLabel "Dimensionless test" $ TestList
+    [ TestCase $ (3 Prelude.** 2) *~ one @=? (3 *~ one) ** (2 *~ one)
+    ]
+
+testShow = TestLabel "Test 'Show' instance" $ TestList
+    [ TestCase $ show (1 *~ one) @?= "1"
+    , TestCase $ show (2 *~ meter) @?= "2 m"
+    , TestCase $ show (2.0 *~ (meter / second)) @?= "2.0 m s^-1"
+    , TestCase $ show (2.0 *~ (meter ^ pos2 / second ^ pos2)) @?= "2.0 m^2 s^-2"
+    , TestCase $ show (undefined :: DVelocity) @?= "m s^-1"
+    ]
+
+-- Collect the test cases.
+tests = TestList
+    [ testPower
+    , testDimensionless
+    , testShow
+    ]
+
+main = runTestTT tests
+
diff --git a/README b/README
new file mode 100644
--- /dev/null
+++ b/README
@@ -0,0 +1,10 @@
+For documentation see the literate haskell source code.
+
+For project information (issues, updates, wiki, examples) see:
+    http://code.google.com/p/dimensional/
+
+To install (requires GHC 6.6 or later):
+    runhaskell Setup.lhs configure
+    runhaskell Setup.lhs build
+    runhaskell Setup.lhs install
+
diff --git a/Test.hs b/Test.hs
new file mode 100644
--- /dev/null
+++ b/Test.hs
@@ -0,0 +1,12 @@
+
+import qualified Numeric.NumTypeTests
+import qualified Numeric.Units.Dimensional.Test
+import qualified Numeric.Units.Dimensional.QuantitiesTest
+import qualified Numeric.Units.Dimensional.ExtensibleTest
+
+main = do
+  Numeric.NumTypeTests.main
+  Numeric.Units.Dimensional.Test.main
+  Numeric.Units.Dimensional.QuantitiesTest.main
+  Numeric.Units.Dimensional.ExtensibleTest.main
+
diff --git a/dimensional.cabal b/dimensional.cabal
--- a/dimensional.cabal
+++ b/dimensional.cabal
@@ -1,5 +1,5 @@
 Name:                dimensional
-Version:             0.7.2
+Version:             0.7.3
 License:             BSD3
 License-File:        LICENSE
 Copyright:           Bjorn Buckwalter 2006-2008
@@ -18,8 +18,9 @@
     far as is practical, enforce/encourage best practices of unit usage.
     Requires GHC 6.6.1 or later.
 Category:            Math
-Build-Depends:       base,
-                     time
+Build-Type:          Simple
+Build-Depends:       base, time
+                     -- , fad
 Exposed-Modules:     Numeric.NumType, 
                      Numeric.Units.Dimensional, 
                      Numeric.Units.Dimensional.Prelude,
@@ -28,5 +29,14 @@
                      Numeric.Units.Dimensional.NonSI,
                      Numeric.Units.Dimensional.Extensible,
                      Numeric.Units.Dimensional.CGS
-ghc-options:         -O
+                     -- , Numeric.Units.Dimensional.ForwardAD
+Extra-source-files:  README,
+                     -- Fad.hs,
+                     Test.hs
+                     Numeric/Units/Dimensional/Test.hs,
+                     Numeric/Units/Dimensional/QuantitiesTest.hs,
+                     Numeric/Units/Dimensional/ExtensibleTest.lhs,
+                     -- , Numeric/Units/Dimensional/ForwardADTest.lhs
+                     examples/README,
+                     examples/GM.lhs
  
diff --git a/examples/GM.lhs b/examples/GM.lhs
new file mode 100644
--- /dev/null
+++ b/examples/GM.lhs
@@ -0,0 +1,93 @@
+
+= GM calculation =
+
+Several representation can be used to describe a satellite's orbit. Two
+of the most popular are the cartesian state vector (position and
+velocity vectors) and the keplerian elements. Conversion between the two
+representations is fairly straight-forward but requires an assumption
+to be made about the universal gravitational constant 'G' and the mass
+'M' of the body the satellite is orbiting. In practice they are often
+combined into a parameter "mu = GM" where the magnitude of 'mu' is
+empirically better known that the magnitudes of 'G' and 'M' individually.
+
+*The problem:* Given two representations of the same satellite orbit -- one
+using the cartesian state vector and using keplerian elements, both at the
+same epoch -- determine the value of 'mu' used to convert between the two.
+{{{
+
+> module GM where
+
+> import Numeric.Units.Dimensional.Prelude
+> import qualified Prelude
+
+}}}
+The state vector describing the orbit at epoch.
+{{{
+
+> x     =   4383.9449203752        *~ kilo meter
+> y     = (-41940.917505092)       *~ kilo meter
+> z     =     22.790255916589      *~ kilo meter
+> x_dot =      3.0575666627812     *~ (kilo meter / second)
+> y_dot =      0.32047068607303    *~ (kilo meter / second)
+> z_dot =      0.00084729371755294 *~ (kilo meter / second)
+
+}}}
+From the state vector we calculate the distance from the reference frame center at epoch and the velocity squared at epoch.
+{{{
+
+> r = sqrt (x ^ pos2 + y ^ pos2 + z ^ pos2)
+> v = sqrt (x_dot ^ pos2 + y_dot ^ pos2 + z_dot ^ pos2)
+
+}}}
+The kinetic energy per unit mass at epoch is a function of the velocity.
+{{{
+
+> e_kin :: EnergyPerUnitMass Double
+> e_kin = v ^ pos2 / _2
+
+}}}
+The only keplerian element we need for this calculation is the semi-major axis.
+{{{
+
+> semi_major_axis = 42165.221455 *~ kilo meter
+
+}}}
+The expression for 'mu' is obtained by solving the following equation system:
+
+    e_pot = - mu / r,
+
+    e_tot = - mu / 2a,
+
+    e_tot = e_pot + e_kin,
+
+which gives:
+
+    mu = e_kin / (1 / r - 1 / 2a).
+
+{{{
+
+> mu = e_kin / (_1 / r - _1 / (_2 * semi_major_axis))
+
+}}}
+Wrap up with a main function showing the value of 'mu' in desired units.
+{{{
+
+> main = putStrLn $ "The value used for GM was " ++ show mu
+
+}}}
+Loading this module in 'ghci' and running 'main' produces the following output.
+{{{
+   ___         ___ _
+  / _ \ /\  /\/ __(_)
+ / /_\// /_/ / /  | |      GHC Interactive, version 6.6.1, for Haskell 98.
+/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
+\____/\/ /_/\____/|_|      Type :? for help.
+
+Loading package base ... linking ... done.
+[1 of 1] Compiling GM               ( GM.lhs, interpreted )
+Ok, modules loaded: GM.
+*GM> main
+Loading package dimensional-0.5 ... linking ... done.
+The value used for GM was 3.986004400008003e14 m^3 s^-2
+*GM>
+}}}
diff --git a/examples/README b/examples/README
new file mode 100644
--- /dev/null
+++ b/examples/README
@@ -0,0 +1,2 @@
+See the project wiki at http://dimensional.googlecode.com for more examples.
+
