diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,5 @@
 .PHONY:	sharedobj
 
-testbuild:
-	runhaskell Setup.lhs configure --user -fbuildExamples --enable-tests
-	runhaskell Setup.lhs build
-#	runhaskell Setup.lhs haddock
-	./dist/build/llvm-extra-test/llvm-extra-test
-
 llvmversion = 2.6
 
 sharedobj:	libLLVM.so
diff --git a/llvm-extra.cabal b/llvm-extra.cabal
--- a/llvm-extra.cabal
+++ b/llvm-extra.cabal
@@ -1,6 +1,6 @@
 Cabal-Version:  2.2
 Name:           llvm-extra
-Version:        0.13.0.1
+Version:        0.13.1
 License:        BSD-3-Clause
 License-File:   LICENSE
 Author:         Henning Thielemann <haskell@henning-thielemann.de>
@@ -63,7 +63,7 @@
   default:     False
 
 Source-Repository this
-  Tag:         0.13.0.1
+  Tag:         0.13.1
   Type:        darcs
   Location:    http://code.haskell.org/~thielema/llvm-extra/
 
@@ -84,7 +84,7 @@
     storable-enum >=0.0 && <0.1,
     bool8 >=0.0 && <0.1,
     transformers >=0.1.1 && <0.7,
-    tagged >=0.7 && <0.9,
+    tagged >=0.7 && <0.10,
     utility-ht >=0.0.15 && <0.1,
     prelude-compat >=0.0 && <0.0.1,
     base-orphans >= 0.5 && <1,
@@ -174,12 +174,14 @@
   Type: exitcode-stdio-1.0
   Build-Depends:
     doctest-exitcode-stdio >=0.0 && <0.1,
+    doctest-lib >=0.1.1 && <0.2,
     QuickCheck >=2.11 && <3,
     private,
     llvm-extra,
     llvm-tf,
     tfp,
     storable-record,
+    non-empty,
     utility-ht >=0.0.1 && <0.1,
     transformers,
     base >=3 && <5
@@ -188,6 +190,10 @@
   Hs-Source-Dirs: test
   Main-Is: Main.hs
   Other-Modules:
+    DocTest.LLVM.Extra.Nice.Value.Vector
+    DocTest.Main
     Test.Storable
     Test.Vector
+    Test.Run
+    Test.RunNice
     LLVM.Extra.VectorAlt
diff --git a/src/LLVM/Extra/Arithmetic.hs b/src/LLVM/Extra/Arithmetic.hs
--- a/src/LLVM/Extra/Arithmetic.hs
+++ b/src/LLVM/Extra/Arithmetic.hs
@@ -268,7 +268,9 @@
    sin, cos, exp, log :: a -> CodeGenFunction r a
    pow :: a -> a -> CodeGenFunction r a
 
-instance (IsFloating a, SoV.TranscendentalConstant a) => Transcendental (Value a) where
+instance
+   (IsFloating a, SoV.TranscendentalConstant a) =>
+      Transcendental (Value a) where
    pi = return $ value SoV.constPi
    sin = Intrinsic.call1 "sin"
    cos = Intrinsic.call1 "cos"
diff --git a/src/LLVM/Extra/Nice/Value/Vector.hs b/src/LLVM/Extra/Nice/Value/Vector.hs
--- a/src/LLVM/Extra/Nice/Value/Vector.hs
+++ b/src/LLVM/Extra/Nice/Value/Vector.hs
@@ -14,6 +14,7 @@
 
    extract, insert,
    replicate,
+   replicateSegmented,
    iterate,
    dissect,
    dissect1,
@@ -48,6 +49,24 @@
 import Prelude (Float, Double, Bool, fmap, (.))
 
 
+{- $setup
+>>> import Test.RunNice (sharedRun, run)
+>>> import qualified LLVM.Extra.Nice.Value.Vector as Vector
+>>> import qualified LLVM.Extra.Nice.Value as NV
+>>> import qualified LLVM.Core as LLVM
+>>> import Type.Data.Num.Decimal (D4, D8)
+>>> import qualified Data.Foldable as Fold
+>>> import qualified Data.List as List
+>>> import qualified Data.NonEmpty as NonEmpty
+>>> import Control.Applicative (liftA2)
+>>> import Data.Int (Int32)
+>>> import Test.QuickCheck ((===))
+>>>
+>>> type N = D8
+>>> type VectorN = LLVM.Vector N
+-}
+
+
 cons ::
    (TypeNum.Positive n, NiceVector.C a) =>
    LLVM.Vector n a -> NVVector n a
@@ -126,11 +145,45 @@
 insert k a = Inst.liftNiceValueM (NiceVector.insert k a)
 
 
+{- |
+>>> run Vector.replicate 42 :: LLVM.Vector D4 Int32
+Vector [42,42,42,42]
+-}
 replicate ::
    (TypeNum.Positive n, NiceVector.C a) =>
    NiceValue.T a -> LLVM.CodeGenFunction r (NVVector n a)
 replicate = fmap Inst.toNiceValue . NiceVector.replicate
 
+{- |
+>>> run (NV.uncurry3 Vector.replicateSegmented) (LLVM.consVector False False True False False True False False, 8, LLVM.consVector 7 6 5 4 3 2 1 0) :: LLVM.Vector D8 Int32
+Vector [8,8,5,5,5,2,2,2]
+
+prop> :{
+   sharedRun (NV.uncurry3 Vector.replicateSegmented) $ \replicateSegmented ->
+   \bs x xs ->
+      NonEmpty.tail
+         (NonEmpty.scanl (\lastX (b,xi) -> if b then xi else lastX)
+            x (liftA2 (,) bs xs))
+      ===
+      replicateSegmented (bs, x, xs :: VectorN Int32)
+:}
+-}
+replicateSegmented ::
+   (TypeNum.Positive n, NiceVector.Select a) =>
+   NVVector n Bool -> NiceValue.T a -> NVVector n a ->
+   LLVM.CodeGenFunction r (NVVector n a)
+replicateSegmented b0 a x0 =
+   Inst.liftNiceValueM2 (\b x -> NiceVector.replicateSegmented b a x) b0 x0
+
+{- |
+prop> :{
+   sharedRun (NV.uncurry (\d -> Vector.iterate (NV.add d))) $ \iter ->
+   \d x ->
+      List.take 8 (List.iterate (d+) x)
+      ===
+      Fold.toList (iter (d,x) :: LLVM.Vector D8 Int32)
+:}
+-}
 iterate ::
    (TypeNum.Positive n, NiceVector.C a) =>
    (NiceValue.T a -> LLVM.CodeGenFunction r (NiceValue.T a)) ->
diff --git a/src/LLVM/Extra/Nice/Vector.hs b/src/LLVM/Extra/Nice/Vector.hs
--- a/src/LLVM/Extra/Nice/Vector.hs
+++ b/src/LLVM/Extra/Nice/Vector.hs
@@ -10,6 +10,7 @@
    map,
    zip, zip3, unzip, unzip3,
    replicate,
+   replicateSegmented,
    iterate,
    take,
    takeRev,
@@ -18,6 +19,8 @@
    dotProduct,
    cumulate,
    cumulate1,
+   cumulateSegmented,
+   cumulate1Segmented,
 
    lift1,
 
@@ -96,7 +99,7 @@
 import Data.Function (flip, (.), ($), )
 import Data.Tuple (snd, )
 import Data.Maybe (maybe, )
-import Data.Ord ((<), )
+import Data.Ord ((<), (<=))
 import Data.Word (Word8, Word16, Word32, Word64, Word)
 import Data.Int (Int8, Int16, Int32, Int64, )
 import Data.Bool8 (Bool8)
@@ -555,8 +558,7 @@
    (TypeNum.Positive n, C a) =>
    [NiceValue.T a] -> CodeGenFunction r (T n a)
 assemble =
-   foldlM (\v (k,x) -> insert (valueOf k) x v) undef .
-   List.zip [0..]
+   foldlM (\v (k,x) -> insert (valueOf k) x v) undef . List.zip [0..]
 
 dissect ::
    (TypeNum.Positive n, C a) =>
@@ -671,6 +673,21 @@
       (List.take (size v0) [0..])
 
 
+replicateSegmented ::
+   (TypeNum.Positive n, Select a) =>
+   T n Bool -> NiceValue.T a -> T n a ->
+   CodeGenFunction r (T n a)
+replicateSegmented b a x =
+   fmap snd $
+   foldlM
+      (\(bi,xi) k ->
+         liftA2 (,)
+            (or bi =<< shiftUpMultiZero k bi)
+            (select bi xi =<< shiftUpMulti a k xi))
+      (b,x)
+      (List.takeWhile (<= size x) $ List.iterate (2*) 1)
+
+
 sum ::
    (TypeNum.Positive n, Additive a) =>
    T n a -> CodeGenFunction r (NiceValue.T a)
@@ -707,6 +724,30 @@
       (List.takeWhile (< size x) $ List.iterate (2*) 1)
 
 
+cumulateSegmented ::
+   (TypeNum.Positive n, Additive a, Select a) =>
+   T n Bool -> NiceValue.T a -> T n a ->
+   CodeGenFunction r (NiceValue.T a, T n a)
+cumulateSegmented b a0 x0 = do
+   (a1,x1) <- shiftUp a0 x0
+   x2 <- cumulate1Segmented b =<< select b zero x1
+   a2 <- A.add a1 =<< last x2
+   return (a2,x2)
+
+cumulate1Segmented ::
+   (TypeNum.Positive n, Additive a, Select a) =>
+   T n Bool -> T n a -> CodeGenFunction r (T n a)
+cumulate1Segmented b x =
+   fmap snd $
+   foldlM
+      (\(bi,xi) k ->
+         liftA2 (,)
+            (or bi =<< shiftUpMultiZero k bi)
+            (add xi =<< select bi zero =<< shiftUpMultiZero k xi))
+      (b,x)
+      (List.takeWhile (< size x) $ List.iterate (2*) 1)
+
+
 -- * re-ordering of elements
 
 constCyclicVector ::
@@ -810,29 +851,49 @@
       (List.takeWhile (< sizev) $ List.iterate (1+) n)
       (NonEmptyC.repeat sizev)
 
+shiftUpMultiGen ::
+   (TypeNum.Positive n, C a) =>
+   T n a -> Int -> T n a -> LLVM.CodeGenFunction r (T n a)
+shiftUpMultiGen a n v =
+   shuffle (shiftUpMultiIndices n (size v)) v a
+
+shiftDownMultiGen ::
+   (TypeNum.Positive n, C a) =>
+   T n a -> Int -> T n a -> LLVM.CodeGenFunction r (T n a)
+shiftDownMultiGen a n v =
+   shuffle (shiftDownMultiIndices n (size v)) v a
+
+shiftUpMulti ::
+   (TypeNum.Positive n, C a) =>
+   NiceValue.T a -> Int -> T n a -> LLVM.CodeGenFunction r (T n a)
+shiftUpMulti a n v =
+   shuffle (shiftUpMultiIndices n (size v)) v =<< replicate a
+
+_shiftDownMulti ::
+   (TypeNum.Positive n, C a) =>
+   NiceValue.T a -> Int -> T n a -> LLVM.CodeGenFunction r (T n a)
+_shiftDownMulti a n v =
+   shuffle (shiftDownMultiIndices n (size v)) v =<< replicate a
+
 shiftUpMultiZero ::
    (TypeNum.Positive n, C a) =>
    Int -> T n a -> LLVM.CodeGenFunction r (T n a)
-shiftUpMultiZero n v =
-   shuffle (shiftUpMultiIndices n (size v)) v zero
+shiftUpMultiZero = shiftUpMultiGen zero
 
 shiftDownMultiZero ::
    (TypeNum.Positive n, C a) =>
    Int -> T n a -> LLVM.CodeGenFunction r (T n a)
-shiftDownMultiZero n v =
-   shuffle (shiftDownMultiIndices n (size v)) v zero
+shiftDownMultiZero = shiftDownMultiGen zero
 
 shiftUpMultiUndef ::
    (TypeNum.Positive n, C a) =>
    Int -> T n a -> LLVM.CodeGenFunction r (T n a)
-shiftUpMultiUndef n v =
-   shuffle (shiftUpMultiIndices n (size v)) v undef
+shiftUpMultiUndef = shiftUpMultiGen undef
 
 shiftDownMultiUndef ::
    (TypeNum.Positive n, C a) =>
    Int -> T n a -> LLVM.CodeGenFunction r (T n a)
-shiftDownMultiUndef n v =
-   shuffle (shiftDownMultiIndices n (size v)) v undef
+shiftDownMultiUndef = shiftDownMultiGen undef
 
 
 -- * method implementations based on Traversable
diff --git a/test/DocTest/LLVM/Extra/Nice/Value/Vector.hs b/test/DocTest/LLVM/Extra/Nice/Value/Vector.hs
new file mode 100644
--- /dev/null
+++ b/test/DocTest/LLVM/Extra/Nice/Value/Vector.hs
@@ -0,0 +1,64 @@
+-- Do not edit! Automatically created with doctest-extract from src/LLVM/Extra/Nice/Value/Vector.hs
+{-# LINE 52 "src/LLVM/Extra/Nice/Value/Vector.hs" #-}
+
+module DocTest.LLVM.Extra.Nice.Value.Vector where
+
+import Test.DocTest.Base
+import qualified Test.DocTest.Driver as DocTest
+
+{-# LINE 53 "src/LLVM/Extra/Nice/Value/Vector.hs" #-}
+import     Test.RunNice (sharedRun, run)
+import     qualified LLVM.Extra.Nice.Value.Vector as Vector
+import     qualified LLVM.Extra.Nice.Value as NV
+import     qualified LLVM.Core as LLVM
+import     Type.Data.Num.Decimal (D4, D8)
+import     qualified Data.Foldable as Fold
+import     qualified Data.List as List
+import     qualified Data.NonEmpty as NonEmpty
+import     Control.Applicative (liftA2)
+import     Data.Int (Int32)
+import     Test.QuickCheck ((===))
+
+type     N = D8
+type     VectorN = LLVM.Vector N
+
+test :: DocTest.T ()
+test = do
+ DocTest.printPrefix "LLVM.Extra.Nice.Value.Vector:149: "
+{-# LINE 149 "src/LLVM/Extra/Nice/Value/Vector.hs" #-}
+ DocTest.example(
+{-# LINE 149 "src/LLVM/Extra/Nice/Value/Vector.hs" #-}
+    run Vector.replicate 42 :: LLVM.Vector D4 Int32
+  )
+  [ExpectedLine [LineChunk "Vector [42,42,42,42]"]]
+ DocTest.printPrefix "LLVM.Extra.Nice.Value.Vector:158: "
+{-# LINE 158 "src/LLVM/Extra/Nice/Value/Vector.hs" #-}
+ DocTest.example(
+{-# LINE 158 "src/LLVM/Extra/Nice/Value/Vector.hs" #-}
+    run (NV.uncurry3 Vector.replicateSegmented) (LLVM.consVector False False True False False True False False, 8, LLVM.consVector 7 6 5 4 3 2 1 0) :: LLVM.Vector D8 Int32
+  )
+  [ExpectedLine [LineChunk "Vector [8,8,5,5,5,2,2,2]"]]
+ DocTest.printPrefix "LLVM.Extra.Nice.Value.Vector:161: "
+{-# LINE 161 "src/LLVM/Extra/Nice/Value/Vector.hs" #-}
+ DocTest.property(
+{-# LINE 161 "src/LLVM/Extra/Nice/Value/Vector.hs" #-}
+        
+   sharedRun (NV.uncurry3 Vector.replicateSegmented) $ \replicateSegmented ->
+   \bs x xs ->
+      NonEmpty.tail
+         (NonEmpty.scanl (\lastX (b,xi) -> if b then xi else lastX)
+            x (liftA2 (,) bs xs))
+      ===
+      replicateSegmented (bs, x, xs :: VectorN Int32)
+  )
+ DocTest.printPrefix "LLVM.Extra.Nice.Value.Vector:179: "
+{-# LINE 179 "src/LLVM/Extra/Nice/Value/Vector.hs" #-}
+ DocTest.property(
+{-# LINE 179 "src/LLVM/Extra/Nice/Value/Vector.hs" #-}
+        
+   sharedRun (NV.uncurry (\d -> Vector.iterate (NV.add d))) $ \iter ->
+   \d x ->
+      List.take 8 (List.iterate (d+) x)
+      ===
+      Fold.toList (iter (d,x) :: LLVM.Vector D8 Int32)
+  )
diff --git a/test/DocTest/Main.hs b/test/DocTest/Main.hs
new file mode 100644
--- /dev/null
+++ b/test/DocTest/Main.hs
@@ -0,0 +1,10 @@
+-- Do not edit! Automatically created with doctest-extract.
+module DocTest.Main where
+
+import qualified DocTest.LLVM.Extra.Nice.Value.Vector
+
+import qualified Test.DocTest.Driver as DocTest
+
+main :: DocTest.T ()
+main = do
+    DocTest.LLVM.Extra.Nice.Value.Vector.test
diff --git a/test/LLVM/Extra/VectorAlt.hs b/test/LLVM/Extra/VectorAlt.hs
--- a/test/LLVM/Extra/VectorAlt.hs
+++ b/test/LLVM/Extra/VectorAlt.hs
@@ -156,7 +156,7 @@
        LLVM.IsPrimitive a, LLVM.IsPrimitive (Mask a),
        LLVM.IsInteger (Mask a)) =>
          Maskable a where
-   type Mask a :: *
+   type Mask a
 
 instance Maskable Int8   where type Mask Int8   = Int8
 instance Maskable Int16  where type Mask Int16  = Int16
diff --git a/test/Main.hs b/test/Main.hs
--- a/test/Main.hs
+++ b/test/Main.hs
@@ -1,5 +1,6 @@
 module Main where
 
+import qualified DocTest.Main as DocTest
 import qualified Test.Storable as Storable
 import qualified Test.Vector as Vector
 
@@ -16,10 +17,12 @@
 main = do
    LLVM.initializeNativeTarget
 
-   DocTest.run $ mapM_
-      (\(msg,prop) -> do
-         DocTest.printPrefix (msg++": ")
-         DocTest.property =<< liftIO prop) $
-      map (mapFst ("Storable."++)) Storable.tests ++
-      map (mapFst ("Vector."++)) Vector.tests ++
-      []
+   DocTest.run $ do
+      DocTest.main
+      mapM_
+         (\(msg,prop) -> do
+            DocTest.printPrefix (msg++": ")
+            DocTest.property =<< liftIO prop) $
+         map (mapFst ("Storable."++)) Storable.tests ++
+         map (mapFst ("Vector."++)) Vector.tests ++
+         []
diff --git a/test/Test/Run.hs b/test/Test/Run.hs
new file mode 100644
--- /dev/null
+++ b/test/Test/Run.hs
@@ -0,0 +1,38 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeOperators #-}
+{-# LANGUAGE TypeFamilies #-}
+module Test.Run where
+
+import qualified LLVM.Extra.Memory as Memory
+import qualified LLVM.ExecutionEngine as EE
+import qualified LLVM.Core as LLVM
+
+import Foreign.Ptr (FunPtr)
+
+
+type Importer func = FunPtr func -> func
+
+generateFunction ::
+   EE.ExecutionFunction f =>
+   Importer f -> LLVM.CodeGenModule (LLVM.Function f) -> IO f
+generateFunction imprt code = do
+   m <- LLVM.newModule
+   fn <- do
+      func <- LLVM.defineModule m $ LLVM.setTarget LLVM.hostTriple >> code
+      EE.runEngineAccessWithModule m $ EE.getExecutionFunction imprt func
+   LLVM.writeBitcodeToFile "test-vector.bc" m
+   return fn
+
+
+foreign import ccall safe "dynamic" derefTestCasePtr ::
+   Importer (LLVM.Ptr inp -> LLVM.Ptr out -> IO ())
+
+modul ::
+   (Memory.C linp, Memory.Struct linp ~ minp, LLVM.IsType minp,
+    Memory.C lout, Memory.Struct lout ~ mout, LLVM.IsType mout) =>
+   (linp -> LLVM.CodeGenFunction () lout) ->
+   LLVM.CodeGenModule (LLVM.Function (LLVM.Ptr minp -> LLVM.Ptr mout -> IO ()))
+modul codegen =
+   LLVM.createFunction LLVM.ExternalLinkage $ \xPtr yPtr -> do
+      flip Memory.store yPtr =<< codegen =<< Memory.load xPtr
+      LLVM.ret ()
diff --git a/test/Test/RunNice.hs b/test/Test/RunNice.hs
new file mode 100644
--- /dev/null
+++ b/test/Test/RunNice.hs
@@ -0,0 +1,40 @@
+module Test.RunNice where
+
+import qualified Test.QuickCheck as QC
+
+import Test.Run (generateFunction, derefTestCasePtr, modul)
+
+import qualified LLVM.Extra.Nice.Value.Marshal as Marshal
+import qualified LLVM.Extra.Nice.Value as NV
+import qualified LLVM.Core as LLVM
+
+import System.IO.Unsafe (unsafePerformIO)
+
+
+sharedRun ::
+   (QC.Testable prop, Marshal.C a, Marshal.C b) =>
+   (NV.T a -> LLVM.CodeGenFunction () (NV.T b)) ->
+   ((a -> b) -> prop) -> QC.Property
+sharedRun f prop =
+   QC.idempotentIOProperty $ do
+      code <- runIO f
+      return $ QC.forAllBlind (return code) prop
+
+run ::
+   (Marshal.C a, Marshal.C b) =>
+   (NV.T a -> LLVM.CodeGenFunction () (NV.T b)) ->
+   a -> b
+run = unsafePerformIO . runIO
+
+runIO ::
+   (Marshal.C a, Marshal.C b) =>
+   (NV.T a -> LLVM.CodeGenFunction () (NV.T b)) ->
+   IO (a -> b)
+runIO f = do
+   funIO <- generateFunction derefTestCasePtr $ modul f
+
+   return $ \a ->
+      unsafePerformIO $
+      Marshal.alloca $ \bPtr ->
+      Marshal.with a $ \aPtr ->
+      funIO aPtr bPtr >> Marshal.peek bPtr
diff --git a/test/Test/Vector.hs b/test/Test/Vector.hs
--- a/test/Test/Vector.hs
+++ b/test/Test/Vector.hs
@@ -4,21 +4,19 @@
 {-# LANGUAGE FlexibleContexts #-}
 module Test.Vector where
 
+import Test.Run (generateFunction, derefTestCasePtr, modul)
+
 import qualified LLVM.Extra.ScalarOrVectorPrivate as SoVPriv
 import qualified LLVM.Extra.ScalarOrVector as SoV
 import qualified LLVM.Extra.VectorAlt as VectorAlt
 import qualified LLVM.Extra.Vector as Vector
-import qualified LLVM.Extra.Memory as Memory
 import qualified LLVM.Extra.Marshal as Marshal
 import qualified LLVM.Extra.Tuple as Tuple
-import qualified LLVM.ExecutionEngine as EE
 import qualified LLVM.Core as LLVM
 
 import qualified Type.Data.Num.Decimal as TypeNum
 import Type.Base.Proxy (Proxy(Proxy))
 
-import Foreign.Ptr (FunPtr)
-
 import qualified Data.Traversable as Trav
 import qualified Data.Foldable as Fold
 import qualified Data.Bits as Bits
@@ -40,40 +38,22 @@
 type V4Int32 = V4 Int32
 type V4Float = V4 Float
 
-type Importer func = FunPtr func -> func
 
-generateFunction ::
-   EE.ExecutionFunction f =>
-   Importer f -> LLVM.CodeGenModule (LLVM.Function f) -> IO f
-generateFunction imprt code = do
-   m <- LLVM.newModule
-   fn <- do
-      func <- LLVM.defineModule m $ LLVM.setTarget LLVM.hostTriple >> code
-      EE.runEngineAccessWithModule m $ EE.getExecutionFunction imprt func
-   LLVM.writeBitcodeToFile "test-vector.bc" m
-   return fn
-
+data Equality a = Equality a a
 
-foreign import ccall safe "dynamic" derefTestCasePtr ::
-   Importer (LLVM.Ptr inp -> LLVM.Ptr out -> IO ())
+infix 4 =!=
 
-modul ::
-   (Memory.C linp, Memory.Struct linp ~ minp, LLVM.IsType minp,
-    Memory.C lout, Memory.Struct lout ~ mout, LLVM.IsType mout) =>
-   (linp -> LLVM.CodeGenFunction () lout) ->
-   LLVM.CodeGenModule (LLVM.Function (LLVM.Ptr minp -> LLVM.Ptr mout -> IO ()))
-modul codegen =
-   LLVM.createFunction LLVM.ExternalLinkage $ \xPtr yPtr -> do
-      flip Memory.store yPtr =<< codegen =<< Memory.load xPtr
-      LLVM.ret ()
+(=!=) :: a -> a -> Equality a
+(=!=) = Equality
 
 run ::
    (Marshal.C inp, Marshal.Struct inp ~ minp, LLVM.IsType minp,
     Marshal.C out, Marshal.Struct out ~ mout, LLVM.IsType mout,
     Tuple.ValueOf inp ~ linp, Tuple.ValueOf out ~ lout) =>
    (Show inp, QC.Arbitrary inp) =>
+   (Show a, Eq a) =>
    (linp -> LLVM.CodeGenFunction () lout) ->
-   (inp -> out -> Bool) ->
+   (inp -> out -> Equality a) ->
    IO QC.Property
 run codegen predicate = do
    funIO <- generateFunction derefTestCasePtr $ modul codegen
@@ -85,7 +65,11 @@
                Marshal.alloca $ \yPtr -> do
                   funIO xPtr yPtr
                   Marshal.peek yPtr
-         QCMon.assert $ predicate x y
+         case predicate x y of
+            Equality a b -> do
+               QCMon.monitor $ QC.counterexample $ show a
+               QCMon.monitor $ QC.counterexample $ show b
+               QCMon.assert $ a==b
 
 
 vec4 :: V4 a -> V4 a
@@ -97,14 +81,14 @@
    (Int32 -> Int32) ->
    IO QC.Property
 unop codegen fun =
-   run codegen (\x y -> fmap fun (vec4 x) == vec4 y)
+   run codegen (\x y -> fmap fun (vec4 x) =!= vec4 y)
 
 unopFloat ::
    (LLVM.Value V4Float -> LLVM.CodeGenFunction () (LLVM.Value V4Float)) ->
    (Float -> Float) ->
    IO QC.Property
 unopFloat codegen fun =
-   run codegen (\x y -> fmap fun (vec4 x) == vec4 y)
+   run codegen (\x y -> fmap fun (vec4 x) =!= vec4 y)
 
 
 binop ::
@@ -116,7 +100,7 @@
    IO QC.Property
 binop codegen fun =
    run (uncurry codegen)
-      (\(x,y) z -> liftA2 fun (vec4 x) (vec4 y)  ==  vec4 z)
+      (\(x,y) z -> liftA2 fun (vec4 x) (vec4 y)  =!=  vec4 z)
 
 binopInt ::
    (LLVM.Value V4Int32 ~ v) =>
@@ -168,7 +152,8 @@
 unpackWord3 = unpackWords 8
 
 binopV4I2 ::
-   (Eq a, LLVM.IsPrimitive a, LLVM.IsSized a, LLVM.SizeOf a ~ TypeNum.D2,
+   (Show a, Eq a,
+    LLVM.IsPrimitive a, LLVM.IsSized a, LLVM.SizeOf a ~ TypeNum.D2,
     LLVM.Value (V4 a) ~ v) =>
    (Word8 -> V4 a) ->
    (v -> v -> LLVM.CodeGenFunction () v) ->
@@ -182,12 +167,13 @@
          vz <- codegen vx vy
          LLVM.bitcast vz)
       (\(x,y) z ->
-         liftA2 fun (unpackBits x) (unpackBits y)  ==  unpackBits z)
+         liftA2 fun (unpackBits x) (unpackBits y)  =!=  unpackBits z)
 
 type Code15 r = LLVM.CodeGenFunction r (LLVM.Value (LLVM.WordN TypeNum.D15))
 
 binopV5I3 ::
-   (Eq a, LLVM.IsPrimitive a, LLVM.IsSized a, LLVM.SizeOf a ~ TypeNum.D3,
+   (Show a, Eq a,
+    LLVM.IsPrimitive a, LLVM.IsSized a, LLVM.SizeOf a ~ TypeNum.D3,
     LLVM.Value (V5 a) ~ v) =>
    (Word16 -> V5 a) ->
    (v -> v -> LLVM.CodeGenFunction () v) ->
@@ -201,7 +187,7 @@
          vz <- codegen vx vy
          LLVM.zext =<< (LLVM.bitcast vz :: Code15 r))
       (\(x,y) z ->
-         liftA2 fun (unpackBits x) (unpackBits y)  ==  unpackBits z)
+         liftA2 fun (unpackBits x) (unpackBits y)  =!=  unpackBits z)
 
 binopInt8 ::
    (LLVM.Value (V4 Int8) ~ v) =>
@@ -298,19 +284,19 @@
       (subSatMan $ convertIntN TypeNum.d2) ++
 
    ("sum",
-      run Vector.sum (\x y -> Fold.sum (vec4 x) == (y::Int32))) :
+      run Vector.sum (\x y -> Fold.sum (vec4 x) =!= (y::Int32))) :
    ("cumulate",
       run
          (uncurry Vector.cumulate)
          (\(x0,xv) (y0,yv) ->
             scanl (+) x0 (Fold.toList (vec4 xv))
-            ==
+            =!=
             Fold.toList (vec4 yv) ++ [y0::Int32])) :
    ("dot",
       run
          (uncurry Vector.dotProduct)
          (\(x,y) z ->
-            Fold.sum (liftA2 (*) (vec4 x) (vec4 y))  ==  (z::Int32))) :
+            Fold.sum (liftA2 (*) (vec4 x) (vec4 y))  =!=  (z::Int32))) :
 
    ("truncate", unopFloat Vector.truncate (fromInteger . P.truncate)) :
    ("floor", unopFloat Vector.floor (fromInteger . P.floor)) :
