title: Haskell - Parsec testing with the help of QuickCheck
body: <p>I'd like to write a tests for a Parsec parser. Here is the example of parser and data structure:</p>
  
  <pre><code>data Event = Event { keyEvent :: String }
      deriving Show
  
  parseKey :: Parser Event
  parseKey = do
               char '&lt;'
               k &lt;- many1 (letter &lt;|&gt; digit &lt;|&gt; oneOf "_")
               char '&gt;'
               return $ Event k
  </code></pre>
  
  <p>I know that I need to check the <code>parse = parse . pretty . parse</code> property. But how should I generate the <em>correct</em> and <em>incorrect</em> test cases? Generally, how should I generate test cases for given <a href="http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form" rel="nofollow noreferrer">BNF</a>? I know about <code>instance Arbitrary</code>, but not much help from this.</p>
  
  <p>I would appreciate if you provide a well-commented example of generator for this simple parser.</p>