Note that there are some explanatory texts on larger screens.

plurals
  1. POWhere do QuickCheck instances belong in a cabal package?
    primarykey
    data
    text
    <p>I have a <a href="https://github.com/acfoltzer/nbt" rel="nofollow noreferrer">cabal package</a> that exports a type <a href="https://github.com/acfoltzer/nbt/blob/master/src/Data/NBT.hs" rel="nofollow noreferrer"><code>NBT</code></a> which might be useful for other developers. I've gone through the trouble of defining an <code>Arbitrary</code> instance for my type, and it would be a shame to not offer it to other developers for testing their code that integrates my work.</p> <p>However, I want to avoid situations where my instance might get in the way. Perhaps the other developer has a <a href="https://stackoverflow.com/questions/5643360/how-do-you-override-haskell-type-class-instances-provided-by-package-code">different idea</a> for what the <code>Arbitrary</code> instance should be. Perhaps my package's dependency on a particular version of QuickCheck might interfere with or be unwanted in the dependencies of the client project.</p> <p>My ideas, in no particular order, are:</p> <ul> <li>Leave the <code>Arbitrary</code> instance next to the definition of the type, and let clients deal with shadowing the instance or overriding the QuickCheck version number.</li> <li>Make the <code>Arbitrary</code> instance an orphan instance in a separate module within the same package, say <code>Data.NBT.Arbitrary</code>. The dependency on QuickCheck for the overall package remains.</li> <li>Offer the <code>Arbitrary</code> instance in a totally separate package, so that it can be listed as a separate test dependency for client projects.</li> <li>Conditionally include both the <code>Arbitrary</code> instance and the QuickCheck dependency in the main package, but only if a flag like <code>-ftest</code> is set.</li> </ul> <p>I've seen combinations of all of these used in other libraries, but haven't found any consensus on which works best. I want to try and get it right before uploading to Hackage.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    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