diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -1,2 +1,50 @@
-import Distribution.Simple
-main = defaultMain
+import Data.List ( nub )
+import Data.Version ( showVersion )
+import Distribution.Package ( PackageName(PackageName), Package, PackageId, InstalledPackageId, packageVersion, packageName )
+import Distribution.PackageDescription ( PackageDescription(), TestSuite(..) )
+import Distribution.Simple ( defaultMainWithHooks, UserHooks(..), simpleUserHooks )
+import Distribution.Simple.Utils ( rewriteFile, createDirectoryIfMissingVerbose, copyFiles )
+import Distribution.Simple.BuildPaths ( autogenModulesDir )
+import Distribution.Simple.Setup ( BuildFlags(buildVerbosity), Flag(..), fromFlag, HaddockFlags(haddockDistPref))
+import Distribution.Simple.LocalBuildInfo ( withLibLBI, withTestLBI, LocalBuildInfo(), ComponentLocalBuildInfo(componentPackageDeps) )
+import Distribution.Text ( display )
+import Distribution.Verbosity ( Verbosity, normal )
+import System.FilePath ( (</>) )
+
+main :: IO ()
+main = defaultMainWithHooks simpleUserHooks
+  { buildHook = \pkg lbi hooks flags -> do
+     generateBuildModule (fromFlag (buildVerbosity flags)) pkg lbi
+     buildHook simpleUserHooks pkg lbi hooks flags
+  , postHaddock = \args flags pkg lbi -> do
+     copyFiles normal (haddockOutputDir flags pkg) [("images","Hierarchy.png")]
+     postHaddock simpleUserHooks args flags pkg lbi
+  }
+
+haddockOutputDir :: Package p => HaddockFlags -> p -> FilePath
+haddockOutputDir flags pkg = destDir where
+  baseDir = case haddockDistPref flags of
+    NoFlag -> "."
+    Flag x -> x
+  destDir = baseDir </> "doc" </> "html" </> display (packageName pkg)
+
+generateBuildModule :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
+generateBuildModule verbosity pkg lbi = do
+  let dir = autogenModulesDir lbi
+  createDirectoryIfMissingVerbose verbosity True dir
+  withLibLBI pkg lbi $ \_ libcfg -> do
+    withTestLBI pkg lbi $ \suite suitecfg -> do
+      rewriteFile (dir </> "Build_" ++ testName suite ++ ".hs") $ unlines
+        [ "module Build_" ++ testName suite ++ " where"
+        , "import Prelude"
+        , "deps :: [String]"
+        , "deps = " ++ (show $ formatdeps (testDeps libcfg suitecfg))
+        ]
+  where
+    formatdeps = map (formatone . snd)
+    formatone p = case packageName p of
+      PackageName n -> n ++ "-" ++ showVersion (packageVersion p)
+
+testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]
+testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys
+
diff --git a/executables/Doctests.hs b/executables/Doctests.hs
new file mode 100644
--- /dev/null
+++ b/executables/Doctests.hs
@@ -0,0 +1,69 @@
+-- The code is mostly ripped from
+-- https://github.com/ekmett/lens/blob/d1d97469f0e93c1d3535308954a060e8a04e37aa/tests/doctests.hsc
+import Prelude
+import Control.Applicative
+import Control.Monad
+import Data.List
+import System.Directory
+import System.FilePath
+import Test.DocTest
+import Build_doctests (deps)
+
+main :: IO ()
+main = do
+  sources <- getSources
+  doctest $ dfltParams ++ map ("-package="++) deps ++ sources
+  where
+    dfltParams = 
+      [
+        "-isrc",
+        "-idist/build/autogen",
+        "-optP-include",
+        "-optPdist/build/autogen/cabal_macros.h",
+        "-XArrows",
+        "-XBangPatterns",
+        "-XConstraintKinds",
+        "-XDataKinds",
+        "-XDefaultSignatures",
+        "-XDeriveDataTypeable",
+        "-XDeriveFunctor",
+        "-XDeriveGeneric",
+        "-XEmptyDataDecls",
+        "-XFlexibleContexts",
+        "-XFlexibleInstances",
+        "-XFunctionalDependencies",
+        "-XGADTs",
+        "-XGeneralizedNewtypeDeriving",
+        "-XImpredicativeTypes",
+        "-XLambdaCase",
+        "-XLiberalTypeSynonyms",
+        "-XMultiParamTypeClasses",
+        "-XMultiWayIf",
+        "-XNoImplicitPrelude",
+        "-XNoMonomorphismRestriction",
+        "-XOverloadedStrings",
+        "-XPatternGuards",
+        "-XParallelListComp",
+        "-XQuasiQuotes",
+        "-XRankNTypes",
+        "-XRecordWildCards",
+        "-XScopedTypeVariables",
+        "-XStandaloneDeriving",
+        "-XTemplateHaskell",
+        "-XTupleSections",
+        "-XTypeFamilies",
+        "-XTypeOperators",
+        "-hide-all-packages"
+      ]
+
+getSources :: IO [FilePath]
+getSources = filter (isSuffixOf ".hs") <$> go "library"
+  where
+    go dir = do
+      (dirs, files) <- getFilesAndDirectories dir
+      (files ++) . concat <$> mapM go dirs
+
+getFilesAndDirectories :: FilePath -> IO ([FilePath], [FilePath])
+getFilesAndDirectories dir = do
+  c <- map (dir </>) . filter (`notElem` ["..", "."]) <$> getDirectoryContents dir
+  (,) <$> filterM doesDirectoryExist c <*> filterM doesFileExist c
diff --git a/executables/InternalTests.hs b/executables/InternalTests.hs
deleted file mode 100644
--- a/executables/InternalTests.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-{-# OPTIONS_GHC -F -pgmF htfpp #-}
-
-import Test.Framework
-import NumericQQ.Prelude
-import NumericQQ
-
-main = htfMain $ htf_thisModulesTests
-
-
-test_basic = do
-  assertEqual 3 [bin|11|]
-  assertEqual 521 [bin|1000001001|]
-  assertEqual 3996 [oct|7634|]
-  assertEqual 41535 [hex|a23f|]
diff --git a/library/NumericQQ.hs b/library/NumericQQ.hs
--- a/library/NumericQQ.hs
+++ b/library/NumericQQ.hs
@@ -15,12 +15,39 @@
 
 type Base = Int
 
+-- |
+-- A binary number quasi-quoter. 
+-- 
+-- >>> [bin|011|]
+-- 3
+-- 
+-- >>> [bin|1000001001|]
+-- 521
+-- 
+-- >>> [bin|11111111|] :: Word8
+-- 255
+-- 
+-- >>> [bin|11111111|] :: Int8
+-- -1
+-- 
 bin :: QuasiQuoter
 bin = qq 2
 
+-- |
+-- An octal number quasi-quoter.
+-- 
+-- >>> [oct|7634|]
+-- 3996
+-- 
 oct :: QuasiQuoter
 oct = qq 8
 
+-- |
+-- A hexadecimal number quasi-quoter.
+-- 
+-- >>> [hex|a23f|]
+-- 41535
+-- 
 hex :: QuasiQuoter
 hex = qq 16
 
diff --git a/numeric-qq.cabal b/numeric-qq.cabal
--- a/numeric-qq.cabal
+++ b/numeric-qq.cabal
@@ -1,11 +1,20 @@
 name:
   numeric-qq
 version:
-  0.1.0
+  0.1.1
 synopsis:
   Quasi-quoters for numbers of different bases
 description:
-  Quasi-quoters for numbers of different bases
+  Quasi-quoters for numeral systems of standard bases:
+  .
+  * Binary (base-2)
+  .
+  * Octal (base-8)
+  .
+  * Hexadecimal (base-16)
+  .
+  All they do is produce integral numbers at compile-time with 
+  compile-time syntax checking.
 category:
   QuasiQoutes, Numeric
 homepage:
@@ -23,7 +32,7 @@
 license-file:
   LICENSE
 build-type:
-  Simple
+  Custom
 cabal-version:
   >=1.10
 
@@ -56,26 +65,22 @@
     Haskell2010
 
 
-test-suite internal-tests
+test-suite doctests
   type:
     exitcode-stdio-1.0
   hs-source-dirs:
     executables
-    library
   main-is:
-    InternalTests.hs
+    Doctests.hs
   ghc-options:
     -threaded
   build-depends:
-    HTF == 0.11.*,
-    -- template-haskell:
-    template-haskell == 2.*,
-    -- debugging:
-    loch-th == 0.2.*,
-    placeholders == 0.1.*,
-    -- general:
+    doctest == 0.9.*,
+    directory == 1.2.*,
+    filepath == 1.3.*,
     base >= 4.5 && < 5
   default-extensions:
     Arrows, BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFunctor, DeriveGeneric, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, ImpredicativeTypes, LambdaCase, LiberalTypeSynonyms, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, TemplateHaskell, TupleSections, TypeFamilies, TypeOperators
   default-language:
     Haskell2010
+
