diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -32,7 +32,9 @@
 `Vector`s.
 
 ````{haskell}
-import qualified Data.Vector as V
+import           Data.Monoid
+
+import qualified Data.Vector          as V
 import           Data.Vector.Distance
 
 -- | Editing vectors of 'Char' values, with '(String, Int, Char)' describing
@@ -40,12 +42,11 @@
 str :: Params Char (String, Int, Char) (Sum Int)
 str = Params
     { equivalent = (==)
-    , delete i c = ("delete", i, c)
-    , insert i c = ("insert", i, c)
-    , substitute i c c' = ("replace", i, c')
-    , cost _ = 1
-    , positionOffset (op,_,_) | op == "delete" = 0
-                              | otherwise      = 1
+    , delete     = \i c    -> ("delete", i, c)
+    , insert     = \i c    -> ("insert", i, c)
+    , substitute = \i c c' -> ("replace", i, c')
+    , cost = const (Sum 1)
+    , positionOffset = \ (op, _, _) -> if op == "delete" then 0 else 1
     }
 
 main :: IO ()
@@ -53,6 +54,9 @@
     print $ leastChanges str (V.fromList "I am thomas")
                              (V.fromList "My name is Thomas")
 ````
+
+(See `test/sample.hs` for a version of this code that is compiled
+by the automated test suite.)
 
 [badge]: https://travis-ci.org/thsutton/edit-distance-vector.svg?branch=master
 [status]: https://travis-ci.org/thsutton/edit-distance-vector
diff --git a/edit-distance-vector.cabal b/edit-distance-vector.cabal
--- a/edit-distance-vector.cabal
+++ b/edit-distance-vector.cabal
@@ -1,5 +1,5 @@
 name:                edit-distance-vector
-version:             1.0.0.2
+version:             1.0.0.3
 synopsis:            Calculate edit distances and edit scripts between vectors.
 description:
   An implementation of the Wagner–Fischer dynamic programming algorithm to
@@ -23,7 +23,7 @@
 copyright:           (c) 2015 Thomas Sutton and others.
 category:            Data, Data Structures, Algorithms
 build-type:          Simple
-extra-source-files:  README.md, CHANGELOG.md
+extra-source-files:  README.md, CHANGELOG.md, test/sample.hs
 cabal-version:       >=1.10
 
 source-repository    HEAD
@@ -44,7 +44,7 @@
   type:                exitcode-stdio-1.0
   hs-source-dirs:      test
   main-is:             properties.hs
-  build-depends:     
+  build-depends:
       base
     , QuickCheck
     , edit-distance-vector
diff --git a/test/sample.hs b/test/sample.hs
new file mode 100644
--- /dev/null
+++ b/test/sample.hs
@@ -0,0 +1,21 @@
+import           Data.Monoid
+
+import qualified Data.Vector          as V
+import           Data.Vector.Distance
+
+-- | Editing vectors of 'Char' values, with '(String, Int, Char)' describing
+--   changes, and the additive monoid of 'Int' describing costs.
+str :: Params Char (String, Int, Char) (Sum Int)
+str = Params
+    { equivalent = (==)
+    , delete     = \i c    -> ("delete", i, c)
+    , insert     = \i c    -> ("insert", i, c)
+    , substitute = \i c c' -> ("replace", i, c')
+    , cost = const (Sum 1)
+    , positionOffset = \ (op, _, _) -> if op == "delete" then 0 else 1
+    }
+
+main :: IO ()
+main = do
+    print $ leastChanges str (V.fromList "I am thomas")
+                             (V.fromList "My name is Thomas")
