diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -1,6 +1,9 @@
 Speculate
 =========
 
+[![Speculate Build Status][build-status]][build-log]
+[![Speculate on Hackage][hackage-version]][speculate-on-hackage]
+
 Speculate automatically discovers laws about Haskell functions.
 Give Speculate a bunch of Haskell functions and it will discover laws like:
 
@@ -146,3 +149,8 @@
 [QuickSpec]: https://github.com/nick8325/quickspec
 [QuickCheck]: https://hackage.haskell.org/package/QuickCheck
 [cmdargs]: https://hackage.haskell.org/package/cmdargs
+
+[build-status]: https://travis-ci.org/rudymatela/speculate.svg?branch=master
+[build-log]:    https://travis-ci.org/rudymatela/speculate
+[hackage-version]: https://img.shields.io/hackage/v/speculate.svg
+[speculate-on-hackage]: https://hackage.haskell.org/package/speculate
diff --git a/speculate.cabal b/speculate.cabal
--- a/speculate.cabal
+++ b/speculate.cabal
@@ -1,5 +1,5 @@
 name:                speculate
-version:             0.2.3
+version:             0.2.4
 synopsis:            discovery of properties about Haskell functions
 description:
   Speculate automatically discovers laws about Haskell functions.
@@ -31,7 +31,7 @@
 source-repository this
   type:            git
   location:        https://github.com/rudymatela/speculate
-  tag:             v0.2.3
+  tag:             v0.2.4
 
 
 library
diff --git a/src/Test/Speculate.hs b/src/Test/Speculate.hs
--- a/src/Test/Speculate.hs
+++ b/src/Test/Speculate.hs
@@ -1,4 +1,10 @@
--- | __ Speculate: discovery of properties by reasoning from test results __
+-- |
+-- Module      : Test.Speculate
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- __ Speculate: discovery of properties by reasoning from test results __
 --
 -- Speculate automatically discovers laws about Haskell functions.
 -- Those laws involve:
diff --git a/src/Test/Speculate/Args.hs b/src/Test/Speculate/Args.hs
--- a/src/Test/Speculate/Args.hs
+++ b/src/Test/Speculate/Args.hs
@@ -1,3 +1,13 @@
+{-# Language DeriveDataTypeable #-} -- for GHC <= 7.8
+-- |
+-- Module      : Test.Speculate.CondReason
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part o Speculate.
+--
+-- Arguments to the 'speculate' function and parsing of command line arguments.
 module Test.Speculate.Args
   ( Args (..)
   , args
@@ -68,6 +78,7 @@
   , showDot      :: Bool       -- ^ __(advanced)__ whether to show a Graphviz dotfile with an Ord lattice
   , quietDot     :: Bool       -- ^ __(advanced)__ whether to show a Graphviz dotfiel with an Ord lattice (less verbose)
   }
+  deriving Typeable -- for GHC <= 7.8
 -- TODO: future options:
 --, closureLimit      :: Int
 --, order             :: OptOrder  -- data OptOrder = Dershowitz | KnuthBendix
@@ -161,11 +172,11 @@
                          && boolTy `elem` map (finalResultTy . typ) (allConstants args)
 
 atoms :: Args -> [Expr]
-atoms args = map holeOfTy ts
+atoms args = nubSort (map holeOfTy ts)
      `union` allConstants args
      `union` [showConstant True  | showConds || showDot args]
      `union` [showConstant False | showConds || showDot args]
-     `union` catMaybes [eqE (computeInstances args) t | t <- ts, showConds]
+     `union` (nubSort . catMaybes) [eqE (computeInstances args) t | t <- ts, showConds]
   where
   ts = types args
   showConds = reallyShowConditions args
diff --git a/src/Test/Speculate/CondReason.hs b/src/Test/Speculate/CondReason.hs
--- a/src/Test/Speculate/CondReason.hs
+++ b/src/Test/Speculate/CondReason.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.CondReason
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part o Speculate.
+--
+-- Conditional equational reasoning.
 module Test.Speculate.CondReason where
 
 import Test.Speculate.Expr
@@ -5,7 +14,8 @@
 import qualified Test.Speculate.Utils.Digraph as D
 import Test.Speculate.Utils.Digraph (Digraph)
 import Data.Maybe (mapMaybe,maybeToList,fromMaybe)
-import Data.List (lookup)
+import Data.List (lookup, sortBy)
+import Data.Function (on)
 import Data.Functor ((<$>)) -- for GHC < 7.10
 import qualified Data.List as L
 import Test.Speculate.Utils
@@ -128,7 +138,7 @@
 
 finalCondEquations :: ((Expr,Expr,Expr) -> Bool) -> Chy -> [(Expr,Expr,Expr)]
 finalCondEquations shouldShow =
-    sortOn (typ . (\(c,x,y) -> x))
+    sortBy (compareTy `on` (\(c,x,y) -> typ x))
   . filter shouldShow
   . cequations
   . cfinalize
diff --git a/src/Test/Speculate/Engine.hs b/src/Test/Speculate/Engine.hs
--- a/src/Test/Speculate/Engine.hs
+++ b/src/Test/Speculate/Engine.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Engine
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Main engine to process data.
 module Test.Speculate.Engine
   ( vassignments
   , expansions
diff --git a/src/Test/Speculate/Expr.hs b/src/Test/Speculate/Expr.hs
--- a/src/Test/Speculate/Expr.hs
+++ b/src/Test/Speculate/Expr.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Expr
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Utilities for manipulating expressions.
 module Test.Speculate.Expr
   ( module Test.Speculate.Expr.Core
   , module Test.Speculate.Expr.Ground
diff --git a/src/Test/Speculate/Expr/Canon.hs b/src/Test/Speculate/Expr/Canon.hs
--- a/src/Test/Speculate/Expr/Canon.hs
+++ b/src/Test/Speculate/Expr/Canon.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Expr.Canon
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Canonicalize and check canonicity of expressions.
 module Test.Speculate.Expr.Canon
   ( canonicalize
   , canonicalizeWith
diff --git a/src/Test/Speculate/Expr/Core.hs b/src/Test/Speculate/Expr/Core.hs
--- a/src/Test/Speculate/Expr/Core.hs
+++ b/src/Test/Speculate/Expr/Core.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Expr.Core
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Defines the 'Expr' type and basic operations on it.
 module Test.Speculate.Expr.Core
   ( Expr (..)
   -- * Smart constructors
@@ -202,9 +211,6 @@
   _             `cmp` Var _ _       = GT
   Var _ _       `cmp` _             = LT
   -- Var < Constants < Apps
-
-compareTy :: TypeRep -> TypeRep -> Ordering
-compareTy = (compare `on` tyArity) <> compare
 
 lexicompareConstants :: Expr -> Expr -> Ordering
 lexicompareConstants = cmp
diff --git a/src/Test/Speculate/Expr/Equate.hs b/src/Test/Speculate/Expr/Equate.hs
--- a/src/Test/Speculate/Expr/Equate.hs
+++ b/src/Test/Speculate/Expr/Equate.hs
@@ -1,10 +1,18 @@
--- | This module exports
---     smart constructors,
---     smart destructors
---   and queries over
---     equations,
---     inequations
---     and conditional equations.
+-- |
+-- Module      : Test.Speculate.Expr.Equate
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- This module exports
+--   smart constructors,
+--   smart destructors
+-- and queries over
+--   equations,
+--   inequations
+--   and conditional equations.
 module Test.Speculate.Expr.Equate
   ( equation, unEquation, isEquation, uselessEquation, usefulEquation
   , phonyEquation
diff --git a/src/Test/Speculate/Expr/Ground.hs b/src/Test/Speculate/Expr/Ground.hs
--- a/src/Test/Speculate/Expr/Ground.hs
+++ b/src/Test/Speculate/Expr/Ground.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Expr.Ground
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Generate and evaluate ground values of expressions.
 module Test.Speculate.Expr.Ground
   ( grounds
   , groundBinds
diff --git a/src/Test/Speculate/Expr/Match.hs b/src/Test/Speculate/Expr/Match.hs
--- a/src/Test/Speculate/Expr/Match.hs
+++ b/src/Test/Speculate/Expr/Match.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Expr.Match
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Matching expressions.
 module Test.Speculate.Expr.Match
   ( Binds
   -- * Assigning
diff --git a/src/Test/Speculate/Expr/TypeInfo.hs b/src/Test/Speculate/Expr/TypeInfo.hs
--- a/src/Test/Speculate/Expr/TypeInfo.hs
+++ b/src/Test/Speculate/Expr/TypeInfo.hs
@@ -1,3 +1,13 @@
+{-# Language DeriveDataTypeable, StandaloneDeriving #-} -- for GHC <= 7.8
+-- |
+-- Module      : Test.Speculate.Expr.TypeInfo
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Typeclass instance information.
 module Test.Speculate.Expr.TypeInfo
   ( Instances
   , Instance (..)
@@ -196,6 +206,8 @@
   where
   m (Ord t' le _) | t == t' = Just le
   m _                       = Nothing
+
+deriving instance Typeable Word2 -- for GHC <= 7.8
 
 -- TODO: include *ALL* prelude types on basicInstances
 preludeInstances :: Instances
diff --git a/src/Test/Speculate/Misc.hs b/src/Test/Speculate/Misc.hs
--- a/src/Test/Speculate/Misc.hs
+++ b/src/Test/Speculate/Misc.hs
@@ -1,5 +1,13 @@
--- | Miscellaneous functions I still did not find a reasonable place to put
---   them in.
+-- |
+-- Module      : Test.Speculate.Misc
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part o Speculate.
+--
+-- Miscellaneous functions I still did not find a reasonable place to put
+-- them in.
 module Test.Speculate.Misc
   ( functions1
   , functions2
diff --git a/src/Test/Speculate/Pretty.hs b/src/Test/Speculate/Pretty.hs
--- a/src/Test/Speculate/Pretty.hs
+++ b/src/Test/Speculate/Pretty.hs
@@ -1,4 +1,12 @@
--- | Pretty printing of Equations, Inequalities and Conditional Equations
+-- |
+-- Module      : Test.Speculate.Pretty
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Pretty printing of Equations, Inequalities and Conditional Equations
 module Test.Speculate.Pretty
   ( prettyThy, prettyEquations
   , prettyShy, prettySemiEquations
diff --git a/src/Test/Speculate/Reason.hs b/src/Test/Speculate/Reason.hs
--- a/src/Test/Speculate/Reason.hs
+++ b/src/Test/Speculate/Reason.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Reason
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Equational reasoning for 'Expr's based on term rewriting.
 module Test.Speculate.Reason
   ( Thy (..)
   , emptyThy
@@ -39,7 +48,6 @@
   , defaultKeep
 
   , reductions1
-  , reductionsO
 
   , dwoBy
   , (|>)
@@ -164,7 +172,7 @@
 reduceRoot e (e1,e2) = (e2 `assigning`) <$> (e `match` e1)
 
 -- Lists all reductions by one rule, note that reductions may be repeated.
--- For unrepeated reductions see reductionsO
+-- @nub . sort@ to remove repetitions
 reductions1 :: Expr -> Rule -> [Expr]
 reductions1 e (l,_) | lengthE l > lengthE e = [] -- optional optimization
 reductions1 e@(e1 :$ e2) r = maybeToList (e `reduceRoot` r)
@@ -172,15 +180,6 @@
                           ++ map (e1 :$) (reductions1 e2 r)
 reductions1 e r = maybeToList (e `reduceRoot` r)
 
--- Lists all reductions by one rule without repetitions.
--- For a faster version that allows repetitions, see reductions1
-reductionsO :: Expr -> Rule -> [Expr]
-reductionsO e (l,_) | lengthE l > lengthE e = [] -- optional optimization
-reductionsO e@(e1 :$ e2) r = maybeToList (e `reduceRoot` r)
-                         +++ map (:$ e2) (reductionsO e1 r)
-                         +++ map (e1 :$) (reductionsO e2 r)
-reductionsO e r = maybeToList (e `reduceRoot` r)
-
 -- as defined by Martin & Nipkow in "Ordered Rewriting and Confluence" on 1990
 -- this definition is sound, but incomplete (some groundJoinable pairs won't be
 -- detected).
@@ -416,7 +415,8 @@
 
 finalEquations :: (Equation -> Bool) -> Instances -> Thy -> [Equation]
 finalEquations shouldShow ti thy =
-    sortOn (typ . fst) . sortBy (compareE thy `on` uncurry phonyEquation)
+    sortBy (compareTy `on` (typ . fst))
+  . sortBy (compareE thy `on` uncurry phonyEquation)
   . filter shouldShow
   $ rules thy' ++ map swap (equations thy')
   where
diff --git a/src/Test/Speculate/Reason/Order.hs b/src/Test/Speculate/Reason/Order.hs
--- a/src/Test/Speculate/Reason/Order.hs
+++ b/src/Test/Speculate/Reason/Order.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Reason.Order
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part o Speculate.
+--
+-- Orders for term rewriting and completion.
 module Test.Speculate.Reason.Order
   ( (|>|)
   , (>|)
diff --git a/src/Test/Speculate/Report.hs b/src/Test/Speculate/Report.hs
--- a/src/Test/Speculate/Report.hs
+++ b/src/Test/Speculate/Report.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Report
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Report Speculate results.
 module Test.Speculate.Report
   ( report
   )
diff --git a/src/Test/Speculate/Sanity.hs b/src/Test/Speculate/Sanity.hs
--- a/src/Test/Speculate/Sanity.hs
+++ b/src/Test/Speculate/Sanity.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Sanity
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Sanity checks for before running the Speculate algorithm.
 module Test.Speculate.Sanity
   ( instanceErrors
   , eqOrdErrors
diff --git a/src/Test/Speculate/SemiReason.hs b/src/Test/Speculate/SemiReason.hs
--- a/src/Test/Speculate/SemiReason.hs
+++ b/src/Test/Speculate/SemiReason.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Misc
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part o Speculate.
+--
+-- Inequational (or semi-equational) reasoning.
 module Test.Speculate.SemiReason where
 
 import Test.Speculate.Expr
@@ -83,7 +92,7 @@
 
 finalSemiEquations :: (Equation -> Bool) -> Instances -> (Expr -> Expr -> Bool) -> Shy -> [Equation]
 finalSemiEquations shouldShow insts equivalentInstanceOf shy =
-    sortOn (typ . fst)
+    sortBy (compareTy `on` (typ . fst))
   . filter shouldShow
   . discardLater (equivalentInstanceOf `on` uncurry phonyEquation)
   . discard (transConsequence shy)
diff --git a/src/Test/Speculate/Utils.hs b/src/Test/Speculate/Utils.hs
--- a/src/Test/Speculate/Utils.hs
+++ b/src/Test/Speculate/Utils.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Utils
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Exports utility functions of all utils sub-modules.
 module Test.Speculate.Utils
   ( module Test.Speculate.Utils.Misc
   , module Test.Speculate.Utils.PrettyPrint
diff --git a/src/Test/Speculate/Utils/Class.hs b/src/Test/Speculate/Utils/Class.hs
--- a/src/Test/Speculate/Utils/Class.hs
+++ b/src/Test/Speculate/Utils/Class.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Utils.Class
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- An equivalence class type and functions to manipulate it.
 module Test.Speculate.Utils.Class
   ( merge
   , mergesOn
diff --git a/src/Test/Speculate/Utils/Colour.hs b/src/Test/Speculate/Utils/Colour.hs
--- a/src/Test/Speculate/Utils/Colour.hs
+++ b/src/Test/Speculate/Utils/Colour.hs
@@ -1,4 +1,12 @@
--- | Simple colour module.
+-- |
+-- Module      : Test.Speculate.Utils.Tuple
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate
+--
+-- Simple colour module.
 module Test.Speculate.Utils.Colour
   ( Colour (RGB)
   , Color
diff --git a/src/Test/Speculate/Utils/Digraph.hs b/src/Test/Speculate/Utils/Digraph.hs
--- a/src/Test/Speculate/Utils/Digraph.hs
+++ b/src/Test/Speculate/Utils/Digraph.hs
@@ -1,3 +1,8 @@
+-- |
+-- Module      : Test.Speculate.Utils.Digraph
+-- Copyright   : (c) 2016 Colin Runciman
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
 module Test.Speculate.Utils.Digraph
   ( Digraph
   , empty
diff --git a/src/Test/Speculate/Utils/List.hs b/src/Test/Speculate/Utils/List.hs
--- a/src/Test/Speculate/Utils/List.hs
+++ b/src/Test/Speculate/Utils/List.hs
@@ -1,10 +1,19 @@
 {-# LANGUAGE CPP #-}
+-- |
+-- Module      : Test.Speculate.Utils.List
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Utilities for manipulating lists.
 module Test.Speculate.Utils.List
   ( pairsThat
   , count, counts, countsBy
   , firsts
   , nubSort, nubSortBy
-  , (+++), nubMerge, nubMergeBy, nubMergeOn, nubMerges, nubMergeMap
+  , (+++), nubMerge, nubMergeBy, nubMergeOn, nubMerges, nubMergesBy, nubMergeMap
   , ordIntersect, ordIntersectBy
   , ordered, orderedBy, orderedOn, strictlyOrdered, strictlyOrderedOn
   , areAll, areAny
@@ -78,9 +87,12 @@
 ordIntersect = ordIntersectBy compare
 
 nubMerges :: Ord a => [[a]] -> [a]
-nubMerges [] = []
-nubMerges [xs] = xs
-nubMerges xss = nubMerges yss `nubMerge` nubMerges zss
+nubMerges = nubMergesBy compare
+
+nubMergesBy :: Ord a => (a -> a -> Ordering) -> [[a]] -> [a]
+nubMergesBy cmp [] = []
+nubMergesBy cmp [xs] = xs
+nubMergesBy cmp xss = nubMergeBy cmp (nubMerges yss) (nubMerges zss)
   where
   (yss,zss) = splitHalf xss
   splitHalf xs = splitAt (length xs `div` 2) xs
diff --git a/src/Test/Speculate/Utils/Memoize.hs b/src/Test/Speculate/Utils/Memoize.hs
--- a/src/Test/Speculate/Utils/Memoize.hs
+++ b/src/Test/Speculate/Utils/Memoize.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Utils.Memoize
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Memoization module.
 module Test.Speculate.Utils.Memoize
   ( memory,     memory2
   , memoryFor,  memory2For
diff --git a/src/Test/Speculate/Utils/Misc.hs b/src/Test/Speculate/Utils/Misc.hs
--- a/src/Test/Speculate/Utils/Misc.hs
+++ b/src/Test/Speculate/Utils/Misc.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Utils.Misc
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Miscellaneous utilities.
 module Test.Speculate.Utils.Misc where
 
 import Test.LeanCheck
diff --git a/src/Test/Speculate/Utils/Ord.hs b/src/Test/Speculate/Utils/Ord.hs
--- a/src/Test/Speculate/Utils/Ord.hs
+++ b/src/Test/Speculate/Utils/Ord.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Utils.Ord
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Utilities for manipulating 'Ordering' values.
 module Test.Speculate.Utils.Ord
   ( module Data.Ord
   , compareIndex
diff --git a/src/Test/Speculate/Utils/PrettyPrint.hs b/src/Test/Speculate/Utils/PrettyPrint.hs
--- a/src/Test/Speculate/Utils/PrettyPrint.hs
+++ b/src/Test/Speculate/Utils/PrettyPrint.hs
@@ -1,4 +1,12 @@
--- | A very simple pretty printing library
+-- |
+-- Module      : Test.Speculate.Utils.PrettyPrint
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- A very simple pretty printing library
 module Test.Speculate.Utils.PrettyPrint
   ( beside
   , above
diff --git a/src/Test/Speculate/Utils/String.hs b/src/Test/Speculate/Utils/String.hs
--- a/src/Test/Speculate/Utils/String.hs
+++ b/src/Test/Speculate/Utils/String.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Utils.String
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Utilities for manipulating strings.
 module Test.Speculate.Utils.String
   ( module Data.String
   , module Data.Char
diff --git a/src/Test/Speculate/Utils/Tiers.hs b/src/Test/Speculate/Utils/Tiers.hs
--- a/src/Test/Speculate/Utils/Tiers.hs
+++ b/src/Test/Speculate/Utils/Tiers.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Utils.Tiers
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Utilities for manipulating tiers of values (of the 'Listable' typeclass).
 module Test.Speculate.Utils.Tiers
   ( productsList
   , mapTMaybe
diff --git a/src/Test/Speculate/Utils/Timeout.hs b/src/Test/Speculate/Utils/Timeout.hs
--- a/src/Test/Speculate/Utils/Timeout.hs
+++ b/src/Test/Speculate/Utils/Timeout.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Utils.Timeout
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Evaluate values to WHNF until a timeout.
 module Test.Speculate.Utils.Timeout
   ( timeoutToNothing
   , fromTimeout
diff --git a/src/Test/Speculate/Utils/Tuple.hs b/src/Test/Speculate/Utils/Tuple.hs
--- a/src/Test/Speculate/Utils/Tuple.hs
+++ b/src/Test/Speculate/Utils/Tuple.hs
@@ -1,3 +1,8 @@
+-- |
+-- Module      : Test.Speculate.Utils.Tuple
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
 module Test.Speculate.Utils.Tuple
   ( module Data.Tuple
   , fst3, fst4
diff --git a/src/Test/Speculate/Utils/Typeable.hs b/src/Test/Speculate/Utils/Typeable.hs
--- a/src/Test/Speculate/Utils/Typeable.hs
+++ b/src/Test/Speculate/Utils/Typeable.hs
@@ -1,3 +1,12 @@
+-- |
+-- Module      : Test.Speculate.Utils.Typeable
+-- Copyright   : (c) 2016-2017 Rudy Matela
+-- License     : 3-Clause BSD  (see the file LICENSE)
+-- Maintainer  : Rudy Matela <rudy@matela.com.br>
+--
+-- This module is part of Speculate.
+--
+-- Utilities to manipulate 'TypeRep's (of 'Typeable' values).
 module Test.Speculate.Utils.Typeable
   ( tyArity
   , typesIn
@@ -9,12 +18,30 @@
   , boolTy
   , mkEqnTy
   , funTyCon
+  , compareTy
   , module Data.Typeable
   )
 where
 
 import Data.Typeable
+import Data.Monoid ((<>))
 import Test.Speculate.Utils.List ((+++))
+
+-- Different versions of Typeable/GHC provide different orderings for TypeReps.
+-- The following is a version independent ordering, with the following
+-- properties:
+--
+-- * functional types with more arguments are larger;
+-- * type constructors with more arguments are larger.
+compareTy :: TypeRep -> TypeRep -> Ordering
+compareTy t1 t2 | t1 == t2 = EQ -- optional optimization
+compareTy t1 t2 = tyArity t1 `compare` tyArity t2
+               <> length ts1 `compare` length ts2
+               <> show c1 `compare` show c2
+               <> foldr (<>) EQ (zipWith compareTy ts1 ts2)
+  where
+  (c1,ts1) = splitTyConApp t1
+  (c2,ts2) = splitTyConApp t2
 
 tyArity :: TypeRep -> Int
 tyArity t
diff --git a/tests/test-expr.hs b/tests/test-expr.hs
--- a/tests/test-expr.hs
+++ b/tests/test-expr.hs
@@ -1,3 +1,4 @@
+{-# Language DeriveDataTypeable, StandaloneDeriving #-} -- Travis
 {-# LANGUAGE CPP #-}
 -- Test library
 import Test
@@ -6,11 +7,17 @@
 -- Functions under test
 import Test.Speculate.Expr
 import Test.Speculate.Utils
+import Test.Speculate.Reason (emptyThy)
 import Data.List (sort)
 import Data.Functor ((<$>)) -- for GHC < 7.10
 import Data.Typeable (typeOf)
 import Data.Maybe (isJust)
 
+-- for Travis:
+deriving instance Typeable Thyght
+deriving instance Typeable Equation
+deriving instance Typeable Expr
+
 main :: IO ()
 main = mainTest tests 10000
 
@@ -67,6 +74,21 @@
   , absE < timesE
   , aa   < ordE
   , ordE < timesE
+
+  -- precedent types
+  , pp < xx
+  , cc < xx
+  , pp < cc
+  , xx < xxs
+  , aa < zero
+  , Test.true < zero
+  , Test.true < aa
+  , zero < ll
+
+  -- further precedent types
+  , constant "xx" xx < zero
+  , constant "xxeqxx" (Equation xx xx) < constant "xx" xx
+  , constant "xx" xx < constant "emptyThyght" (Thyght emptyThy)
 
   , unfoldApp (abs' xx)          == [absE, xx]
   , unfoldApp (abs' (xx -+- yy)) == [absE, xx -+- yy]
