stock-quickcheck: Derive Arbitrary via the stock plugin
The stock plugin
provides a newtype
Stock
for deriving and synthesising instances at compile
time. stock-quickcheck extends it to support
Arbitrary,
CoArbitrary,
and their higher-kinded variants.
{-# options_ghc -fplugin Stock #-}
{-# language DerivingVia #-}
{-# language DataKinds #-}
import Stock
import Stock.QuickCheck
import Test.QuickCheck
data Person = P { name :: String, age :: Int }
deriving (Eq, Ord, Show, Read) via
Stock Person
deriving Arbitrary via
Overriding Person
[ name via ASCIIString, age via Positive ]stock-quickcheck provides four instances, that signal to the
plugin how to derive Arbitrary,
Arbitrary1,
Arbitrary2 and
CoArbitrary.
arbitrary is structural and size-aware, in the style of
generic-arbitrary.
It picks a constructor, preferring terminal constructors once the
size runs out, so recursive types terminate, and fills each field
with its own arbitrary, dividing the size among recursive
fields. shrink defaults.
instance DeriveStock Arbitrary .. instance DeriveStock1 Arbitrary1 .. instance DeriveStock2 Arbitrary2 .. instance DeriveStock CoArbitrary ..
stock companion packages include:
stock-aeson:ToJSON,ToJSON1,ToJSON2;FromJSON,FromJSON1,FromJSON2stock-quickcheck:Arbitrary,Arbitrary1,Arbitrary2;CoArbitrary
Downloads
- stock-quickcheck-0.1.0.0.tar.gz [browse] (Cabal source package)
- Package description (revised from the package)
Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
| Versions [RSS] | 0.1.0.0 |
|---|---|
| Dependencies | base (>=4.18 && <5), ghc (>=9.6 && <9.16), QuickCheck (>=2.14 && <2.19), stock (>=0.1 && <0.2) [details] |
| Tested with | ghc ==9.8.1, ghc ==9.10.3, ghc ==9.12.4, ghc ==9.14.1, ghc ==9.10.3, ghc ==9.12.4, ghc ==9.14.1 |
| License | BSD-3-Clause |
| Author | Baldur Blöndal |
| Maintainer | baldur.blondal@iohk.io |
| Uploaded | by BaldurBlondal at 2026-06-23T15:43:51Z |
| Revised | Revision 5 made by BaldurBlondal at 2026-06-24T01:43:56Z |
| Category | Type System |
| Source repo | head: git clone https://github.com/Icelandjack/stock.git(quickcheck) |
| Distributions | |
| Downloads | 3 total (3 in the last 30 days) |
| Rating | (no votes yet) [estimated by Bayesian average] |
| Your Rating | |
| Status | Docs available [build log] Last success reported on 2026-06-23 [all 1 reports] |