title: Haskell QuickCheck best practices (especially when testing type classes)
body: <p>I've just started using QuickCheck with a bunch of Haskell code. I'm behind the times, I know. This question is a two-parter:</p>
  
  <p>Firstly, what are the general best-practices for Quick Check? So far, I've picked up the following:</p>
  
  <ul>
  <li>Name your tests prop_* (annoying, because everything else is camelCase)</li>
  <li>Test exported code (if you're testing internals you're likely doing it wrong)</li>
  <li>Test properties, not examples
  <ul>
  <li>Don't say <code>X is out of range, Y is in range</code></li>
  <li>Instead, say <code>if x is out of range, normalize x ≠ x</code> (or some other such property)</li>
  </ul></li>
  </ul>
  
  <p>But I'm still grasping at other best practices. Particularly:</p>
  
  <ul>
  <li>Where are properties kept?
  <ul>
  <li>The same file?</li>
  <li>in a <code>test/</code> directory? (If so, then how do you import the stuff in <code>src/</code>?)</li>
  <li>in a <code>Properties/</code> directory under <code>src</code>?</li>
  </ul></li>
  </ul>
  
  <p>Most importantly, how do we tend to go about testing properties on type classes? For example, consider the following (simplified) type class:</p>
  
  <pre><code>class Gen a where
      next :: a -&gt; a
      prev :: a -&gt; a
  </code></pre>
  
  <p>I'd like to test the property <code>∀ x: prev (next x) == x</code>. Of course, this involves writing tests for each instance. It's tedious to write the same property for each instance, especially when the test is more complicated. What's the standard way to generalize such tests?</p>