Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>QuickCheck looks for <em>counterexamples</em>. So you need to provide a negation of the property you seek:</p> <pre><code>prop1 f g x = not $ (f . g) x == (g . f) x </code></pre> <p>This particular property don't specify function type - any function of <code>a -&gt; a</code> could work. So you need to specify types for <code>f</code> and <code>g</code>, or for whole function <code>prop1</code>.</p> <ol> <li><p>You cannot compare <code>f . g</code> and <code>g . f</code> for equality because they are both functions and you cannot have a sensible definition of <code>Eq</code> for functions with infinite domains in Haskell. You need to randomly generate the argument too and compare the <code>f . g</code> and <code>g . f</code> functions by comparing their results by passing a random argument to both.</p></li> <li><p>Read the <a href="http://hackage.haskell.org/packages/archive/QuickCheck/2.4.1.1/doc/html/Test-QuickCheck-Function.html%20documentation" rel="nofollow">documentation</a> on the type of <code>Fun _ f</code>. <code>f</code> there is a <em>monomorphic</em> function. QuickCheck cannot generate random functions of different types - it can only generate functions of some particular type. But <code>.</code> is <em>polymorphic</em>, so the particular type of f cannot be inferred from the context. So you need to choose some arbitrary types for <code>f</code> and <code>g</code> and specify it in the type signature for your property.</p></li> </ol> <p>Also, you don't need <code>let</code> for top-level definitions. Let can be only used inside of expressions in the form of <code>let..in</code> and inside <code>do</code> blocks without <code>in</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload