This file is indexed.

/usr/share/doc/libghc-quickcheck2-doc/html/Test-QuickCheck-Monadic.html is in libghc-quickcheck2-doc 2.9.2-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Test.QuickCheck.Monadic</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="file:///usr/share/javascript/mathjax/MathJax.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Test-QuickCheck-Monadic.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Test-QuickCheck-Monadic.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">QuickCheck-2.9.2: Automatic testing of Haskell programs</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>Safe</td></tr><tr><th>Language</th><td>Haskell98</td></tr></table><p class="caption">Test.QuickCheck.Monadic</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Property monad</a></li><li><a href="#g:2">Monadic specification combinators</a></li><li><a href="#g:3">Run functions</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Allows testing of monadic values. Will generally follow this form:</p><pre>prop_monadic a b = <code><a href="Test-QuickCheck-Monadic.html#v:monadicIO">monadicIO</a></code> $ do
  a' &lt;- <code><a href="Test-QuickCheck-Monadic.html#v:run">run</a></code> (f a)
  b' &lt;- <code><a href="Test-QuickCheck-Monadic.html#v:run">run</a></code> (f b)
  -- ...
  <code><a href="Test-QuickCheck-Monadic.html#v:assert">assert</a></code> someBoolean
</pre><p>Example using the <code>FACTOR(1)</code> command-line utility:</p><pre>import System.Process
import Test.QuickCheck
import Test.QuickCheck.Monadic

-- $ factor 16
-- 16: 2 2 2 2
factor :: Integer -&gt; IO [Integer]
factor n = parse `fmap` <code><a href="System-Process.html#v:readProcess">readProcess</a></code> &quot;factor&quot; [show n] &quot;&quot; where

  parse :: String -&gt; [Integer]
  parse = map read . tail . words

prop_factor :: Positive Integer -&gt; Property
prop_factor (<code><a href="Test-QuickCheck-Modifiers.html#v:Positive">Positive</a></code> n) = <code><a href="Test-QuickCheck-Monadic.html#v:monadicIO">monadicIO</a></code> $ do
  factors &lt;- <code><a href="Test-QuickCheck-Monadic.html#v:run">run</a></code> (factor n)

  <code><a href="Test-QuickCheck-Monadic.html#v:assert">assert</a></code> (product factors == n)
</pre><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>quickCheck prop_factor
</code></strong>+++ OK, passed 100 tests.
</pre><p>See the paper &quot;<a href="http://www.cse.chalmers.se/~rjmh/Papers/QuickCheckST.ps">Testing Monadic Code with QuickCheck</a>&quot;.</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">newtype</span> <a href="#t:PropertyM">PropertyM</a> m a = <a href="#v:MkPropertyM">MkPropertyM</a> {<ul class="subs"><li><a href="#v:unPropertyM">unPropertyM</a> :: (a -&gt; <a href="Test-QuickCheck-Gen.html#t:Gen">Gen</a> (m <a href="Test-QuickCheck-Property.html#t:Property">Property</a>)) -&gt; <a href="Test-QuickCheck-Gen.html#t:Gen">Gen</a> (m <a href="Test-QuickCheck-Property.html#t:Property">Property</a>)</li></ul>}</li><li class="src short"><a href="#v:run">run</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; m a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a</li><li class="src short"><a href="#v:assert">assert</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m ()</li><li class="src short"><a href="#v:pre">pre</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m ()</li><li class="src short"><a href="#v:wp">wp</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; m a -&gt; (a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m b) -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m b</li><li class="src short"><a href="#v:pick">pick</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-Show.html#t:Show">Show</a> a) =&gt; <a href="Test-QuickCheck-Gen.html#t:Gen">Gen</a> a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a</li><li class="src short"><a href="#v:forAllM">forAllM</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-Show.html#t:Show">Show</a> a) =&gt; <a href="Test-QuickCheck-Gen.html#t:Gen">Gen</a> a -&gt; (a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m b) -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m b</li><li class="src short"><a href="#v:monitor">monitor</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; (<a href="Test-QuickCheck-Property.html#t:Property">Property</a> -&gt; <a href="Test-QuickCheck-Property.html#t:Property">Property</a>) -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m ()</li><li class="src short"><a href="#v:stop">stop</a> :: (<a href="Test-QuickCheck-Property.html#t:Testable">Testable</a> prop, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m) =&gt; prop -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a</li><li class="src short"><a href="#v:monadic">monadic</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; (m <a href="Test-QuickCheck-Property.html#t:Property">Property</a> -&gt; <a href="Test-QuickCheck-Property.html#t:Property">Property</a>) -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a -&gt; <a href="Test-QuickCheck-Property.html#t:Property">Property</a></li><li class="src short"><a href="#v:monadic-39-">monadic'</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a -&gt; <a href="Test-QuickCheck-Gen.html#t:Gen">Gen</a> (m <a href="Test-QuickCheck-Property.html#t:Property">Property</a>)</li><li class="src short"><a href="#v:monadicIO">monadicIO</a> :: <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> a -&gt; <a href="Test-QuickCheck-Property.html#t:Property">Property</a></li><li class="src short"><a href="#v:monadicST">monadicST</a> :: (<span class="keyword">forall</span> s. <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad-ST.html#t:ST">ST</a> s) a) -&gt; <a href="Test-QuickCheck-Property.html#t:Property">Property</a></li><li class="src short"><a href="#v:runSTGen">runSTGen</a> :: (<span class="keyword">forall</span> s. <a href="Test-QuickCheck-Gen.html#t:Gen">Gen</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad-ST.html#t:ST">ST</a> s a)) -&gt; <a href="Test-QuickCheck-Gen.html#t:Gen">Gen</a> a</li></ul></div><div id="interface"><h1 id="g:1">Property monad</h1><div class="top"><p class="src"><span class="keyword">newtype</span> <a id="t:PropertyM" class="def">PropertyM</a> m a <a href="src/Test-QuickCheck-Monadic.html#PropertyM" class="link">Source</a> <a href="#t:PropertyM" class="selflink">#</a></p><div class="doc"><p>The property monad is really a monad transformer that can contain
 monadic computations in the monad <code>m</code> it is parameterized by:</p><ul><li><code>m</code> - the <code>m</code>-computations that may be performed within <code>PropertyM</code></li></ul><p>Elements of <code>PropertyM m a</code> may mix property operations and <code>m</code>-computations.</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:MkPropertyM" class="def">MkPropertyM</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><ul><li><dfn class="src"><a id="v:unPropertyM" class="def">unPropertyM</a> :: (a -&gt; <a href="Test-QuickCheck-Gen.html#t:Gen">Gen</a> (m <a href="Test-QuickCheck-Property.html#t:Property">Property</a>)) -&gt; <a href="Test-QuickCheck-Gen.html#t:Gen">Gen</a> (m <a href="Test-QuickCheck-Property.html#t:Property">Property</a>)</dfn><div class="doc empty">&nbsp;</div></li></ul></div></td></tr></table></div><div class="subs instances"><p id="control.i:PropertyM" class="caption collapser" onclick="toggleSection('i:PropertyM')">Instances</p><div id="section.i:PropertyM" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:PropertyM:MonadTrans:1" class="instance expander" onclick="toggleSection('i:id:PropertyM:MonadTrans:1')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Class.html#t:MonadTrans">MonadTrans</a> <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a></span> <a href="src/Test-QuickCheck-Monadic.html#line-111" class="link">Source</a> <a href="#t:PropertyM" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:PropertyM:MonadTrans:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:lift">lift</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; m a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a <a href="#v:lift" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:PropertyM:Monad:2" class="instance expander" onclick="toggleSection('i:id:PropertyM:Monad:2')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> (<a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m)</span> <a href="src/Test-QuickCheck-Monadic.html#line-105" class="link">Source</a> <a href="#t:PropertyM" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:PropertyM:Monad:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-62--62--61-">(&gt;&gt;=)</a> :: <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a -&gt; (a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m b) -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m b <a href="#v:-62--62--61-" class="selflink">#</a></p><p class="src"><a href="#v:-62--62-">(&gt;&gt;)</a> :: <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m b -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m b <a href="#v:-62--62-" class="selflink">#</a></p><p class="src"><a href="#v:return">return</a> :: a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a <a href="#v:return" class="selflink">#</a></p><p class="src"><a href="#v:fail">fail</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a <a href="#v:fail" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:PropertyM:Functor:3" class="instance expander" onclick="toggleSection('i:id:PropertyM:Functor:3')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Functor.html#t:Functor">Functor</a> (<a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m)</span> <a href="src/Test-QuickCheck-Monadic.html#line-98" class="link">Source</a> <a href="#t:PropertyM" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:PropertyM:Functor:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fmap">fmap</a> :: (a -&gt; b) -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m b <a href="#v:fmap" class="selflink">#</a></p><p class="src"><a href="#v:-60--36-">(&lt;$)</a> :: a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m b -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a <a href="#v:-60--36-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:PropertyM:Applicative:4" class="instance expander" onclick="toggleSection('i:id:PropertyM:Applicative:4')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Applicative.html#t:Applicative">Applicative</a> (<a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m)</span> <a href="src/Test-QuickCheck-Monadic.html#line-101" class="link">Source</a> <a href="#t:PropertyM" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:PropertyM:Applicative:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:pure">pure</a> :: a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a <a href="#v:pure" class="selflink">#</a></p><p class="src"><a href="#v:-60--42--62-">(&lt;*&gt;)</a> :: <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m (a -&gt; b) -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m b <a href="#v:-60--42--62-" class="selflink">#</a></p><p class="src"><a href="#v:-42--62-">(*&gt;)</a> :: <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m b -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m b <a href="#v:-42--62-" class="selflink">#</a></p><p class="src"><a href="#v:-60--42-">(&lt;*)</a> :: <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m b -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a <a href="#v:-60--42-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:PropertyM:MonadIO:5" class="instance expander" onclick="toggleSection('i:id:PropertyM:MonadIO:5')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad-IO-Class.html#t:MonadIO">MonadIO</a> m =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad-IO-Class.html#t:MonadIO">MonadIO</a> (<a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m)</span> <a href="src/Test-QuickCheck-Monadic.html#line-114" class="link">Source</a> <a href="#t:PropertyM" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:PropertyM:MonadIO:5" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:liftIO">liftIO</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a <a href="#v:liftIO" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><h1 id="g:2">Monadic specification combinators</h1><div class="top"><p class="src"><a id="v:run" class="def">run</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; m a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a <a href="src/Test-QuickCheck-Monadic.html#run" class="link">Source</a> <a href="#v:run" class="selflink">#</a></p><div class="doc"><p>The lifting operation of the property monad. Allows embedding
 monadic/<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a></code>-actions in properties:</p><pre>log :: Int -&gt; IO ()

prop_foo n = monadicIO $ do
  run (log n)
  -- ...
</pre></div></div><div class="top"><p class="src"><a id="v:assert" class="def">assert</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m () <a href="src/Test-QuickCheck-Monadic.html#assert" class="link">Source</a> <a href="#v:assert" class="selflink">#</a></p><div class="doc"><p>Allows embedding non-monadic properties into monadic ones.</p></div></div><div class="top"><p class="src"><a id="v:pre" class="def">pre</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m () <a href="src/Test-QuickCheck-Monadic.html#pre" class="link">Source</a> <a href="#v:pre" class="selflink">#</a></p><div class="doc"><p>Tests preconditions. Unlike <code><a href="Test-QuickCheck-Monadic.html#v:assert">assert</a></code> this does not cause the
 property to fail, rather it discards them just like using the
 implication combinator <code><a href="Test-QuickCheck-Property.html#v:-61--61--62-">==&gt;</a></code>.</p><p>This allows representing the <a href="https://en.wikipedia.org/wiki/Hoare_logic">Hoare triple</a></p><pre>{p} x &#8592; e{q}</pre><p>as</p><pre>pre p
x &lt;- run e
assert q
</pre></div></div><div class="top"><p class="src"><a id="v:wp" class="def">wp</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; m a -&gt; (a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m b) -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m b <a href="src/Test-QuickCheck-Monadic.html#wp" class="link">Source</a> <a href="#v:wp" class="selflink">#</a></p><div class="doc"><p>The <a href="https://en.wikipedia.org/wiki/Predicate_transformer_semantics#Weakest_preconditions">weakest precondition</a></p><pre>wp(x &#8592; e, p)</pre><p>can be expressed as in code as <code>wp e (\x -&gt; p)</code>.</p></div></div><div class="top"><p class="src"><a id="v:pick" class="def">pick</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-Show.html#t:Show">Show</a> a) =&gt; <a href="Test-QuickCheck-Gen.html#t:Gen">Gen</a> a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a <a href="src/Test-QuickCheck-Monadic.html#pick" class="link">Source</a> <a href="#v:pick" class="selflink">#</a></p><div class="doc"><p>Quantification in a monadic property, fits better with
 <em>do-notation</em> than <code><a href="Test-QuickCheck-Monadic.html#v:forAllM">forAllM</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:forAllM" class="def">forAllM</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-Show.html#t:Show">Show</a> a) =&gt; <a href="Test-QuickCheck-Gen.html#t:Gen">Gen</a> a -&gt; (a -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m b) -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m b <a href="src/Test-QuickCheck-Monadic.html#forAllM" class="link">Source</a> <a href="#v:forAllM" class="selflink">#</a></p><div class="doc"><p>An alternative to quantification a monadic properties to <code><a href="Test-QuickCheck-Monadic.html#v:pick">pick</a></code>,
 with a notation similar to <code><a href="Test-QuickCheck-Property.html#v:forAll">forAll</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:monitor" class="def">monitor</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; (<a href="Test-QuickCheck-Property.html#t:Property">Property</a> -&gt; <a href="Test-QuickCheck-Property.html#t:Property">Property</a>) -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m () <a href="src/Test-QuickCheck-Monadic.html#monitor" class="link">Source</a> <a href="#v:monitor" class="selflink">#</a></p><div class="doc"><p>Allows making observations about the test data:</p><pre>monitor (<code><a href="Test-QuickCheck-Property.html#v:collect">collect</a></code> e)
</pre><p>collects the distribution of value of <code>e</code>.</p><pre>monitor (<code><a href="Test-QuickCheck-Property.html#v:counterexample">counterexample</a></code> &quot;Failure!&quot;)
</pre><p>Adds <code>&quot;Failure!&quot;</code> to the counterexamples.</p></div></div><div class="top"><p class="src"><a id="v:stop" class="def">stop</a> :: (<a href="Test-QuickCheck-Property.html#t:Testable">Testable</a> prop, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m) =&gt; prop -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a <a href="src/Test-QuickCheck-Monadic.html#stop" class="link">Source</a> <a href="#v:stop" class="selflink">#</a></p></div><h1 id="g:3">Run functions</h1><div class="top"><p class="src"><a id="v:monadic" class="def">monadic</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; (m <a href="Test-QuickCheck-Property.html#t:Property">Property</a> -&gt; <a href="Test-QuickCheck-Property.html#t:Property">Property</a>) -&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a -&gt; <a href="Test-QuickCheck-Property.html#t:Property">Property</a> <a href="src/Test-QuickCheck-Monadic.html#monadic" class="link">Source</a> <a href="#v:monadic" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:monadic-39-" class="def">monadic'</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> m a -&gt; <a href="Test-QuickCheck-Gen.html#t:Gen">Gen</a> (m <a href="Test-QuickCheck-Property.html#t:Property">Property</a>) <a href="src/Test-QuickCheck-Monadic.html#monadic%27" class="link">Source</a> <a href="#v:monadic-39-" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:monadicIO" class="def">monadicIO</a> :: <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> a -&gt; <a href="Test-QuickCheck-Property.html#t:Property">Property</a> <a href="src/Test-QuickCheck-Monadic.html#monadicIO" class="link">Source</a> <a href="#v:monadicIO" class="selflink">#</a></p><div class="doc"><p>Runs the property monad for <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a></code>-computations.</p><pre>prop_cat msg = monadicIO $ do
  (exitCode, stdout, _) &lt;- run (<code><a href="System-Process.html#v:readProcessWithExitCode">readProcessWithExitCode</a></code> &quot;cat&quot; [] msg)

  pre (<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-Exit.html#v:ExitSuccess">ExitSuccess</a></code> == exitCode)

  assert (stdout == msg)
</pre><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>quickCheck prop_cat
</code></strong>+++ OK, passed 100 tests.
</pre></div></div><div class="top"><p class="src"><a id="v:monadicST" class="def">monadicST</a> :: (<span class="keyword">forall</span> s. <a href="Test-QuickCheck-Monadic.html#t:PropertyM">PropertyM</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad-ST.html#t:ST">ST</a> s) a) -&gt; <a href="Test-QuickCheck-Property.html#t:Property">Property</a> <a href="src/Test-QuickCheck-Monadic.html#monadicST" class="link">Source</a> <a href="#v:monadicST" class="selflink">#</a></p><div class="doc"><p>Runs the property monad for <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad-ST.html#t:ST">ST</a></code>-computations.</p><pre>-- Your mutable sorting algorithm here
sortST :: Ord a =&gt; [a] -&gt; <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad-ST.html#t:ST">ST</a></code> s (MVector s a)
sortST = <code><a href="Data-Vector.html#v:thaw">thaw</a></code> . <code><a href="Data-Vector.html#v:fromList">fromList</a></code> . <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-List.html#v:sort">sort</a></code>

prop_sortST xs = monadicST $ do
  sorted  &lt;- run (<code><a href="Data-Vector.html#v:freeze">freeze</a></code> =&lt;&lt; sortST xs)
  assert (<code><a href="Data-Vector.html#v:toList">toList</a></code> sorted == sort xs)
</pre><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>quickCheck prop_sortST
</code></strong>+++ OK, passed 100 tests.
</pre></div></div><div class="top"><p class="src"><a id="v:runSTGen" class="def">runSTGen</a> :: (<span class="keyword">forall</span> s. <a href="Test-QuickCheck-Gen.html#t:Gen">Gen</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad-ST.html#t:ST">ST</a> s a)) -&gt; <a href="Test-QuickCheck-Gen.html#t:Gen">Gen</a> a <a href="src/Test-QuickCheck-Monadic.html#runSTGen" class="link">Source</a> <a href="#v:runSTGen" class="selflink">#</a></p></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.3</p></div></body></html>