Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- deriveArbitrary :: TacticsM ()
- data Generator = Generator {}
- mkGenerator :: TyCon -> [Type] -> DataCon -> Generator
- doesTypeContain :: TyCon -> Type -> Bool
- mkArbitraryCall :: TyCon -> Integer -> Type -> HsExpr GhcPs
Documentation
deriveArbitrary :: TacticsM () Source #
Known tactic for deriving arbitrary :: Gen a
. This tactic splits the
type's data cons into terminal and inductive cases, and generates code that
produces a terminal if the QuickCheck size parameter is <=1, or any data con
otherwise. It correctly scales recursive parameters, ensuring termination.
Helper data type for the generator of a specific data con.
mkGenerator :: TyCon -> [Type] -> DataCon -> Generator Source #
Make a Generator
for a given tycon instantiated with the given [Type]
.
mkArbitraryCall :: TyCon -> Integer -> Type -> HsExpr GhcPs Source #
Generate the correct sort of call to arbitrary
. For recursive calls, we
need to scale down the size parameter, either by a constant factor of 1 if
it's the only recursive parameter, or by
where n is the number of
recursive parameters. For all other types, just call div
narbitrary
directly.