sol/doctest-haskell — pull request #74 by nick8325 (2014-02-20 21:27:39+00:00)
Title: Monomorphise QuickCheck properties before running them

GHCi defaults any ambiguous type variables to () - this has the unfortunate effect that something like

-- |
-- prop> reverse xs == xs

will _pass_, because reversing a list of units does give you the same list back!

To help with this problem, QuickCheck has a Template Haskell-based monomorphiser that instantiates all ambiguous type variables to Integer instead. This patch makes doctest use that monomorphiser. The code we run in GHCi is

let doctest_prop xs = reverse xs == xs in $(polyQuickCheck 'doctest_prop)

which instantiates doctest_prop at the type [Integer] -> Bool, and we get the expected counterexample, [0,1].