hedgehog-gen-0.1.0.0: Customizable Gen for ADT using Generics

Safe HaskellNone
LanguageHaskell2010

Hedgehog.Gen.Generic

Synopsis

Documentation

mkGen Source #

Arguments

:: (Generic a, GMkGen (Rep a) '[], Typeable a) 
=> GenMap

Map containing type-based and field-based overrides of Gen

-> Gen a

Generator for any a having Generic instance

mkGen creates a Gen for any a having Generic. mkGen assumes Generic instance is present for all the types in the the transitive dependency of a.

mkGenWith Source #

Arguments

:: (Generic a, GMkGen (Rep a) glist, Typeable a) 
=> GenList glist

HList of Gens for types not having Generic instance

-> GenMap

Map containing type-based and field-based overrides of Gen

-> Gen a

Generator for any a having Generic instance

mkGenWith creates a Gen for any a having Generic. It is same as mkGen, except that it takes HList of Gens for all types not having Generic instance in the transitive dependency of a

emptyGens :: GenMap Source #

emptyGens creates a empty map of overrides.

byType :: Typeable t => Gen t -> GenMap -> GenMap Source #

byType is used to override the Gen for type t. This have lower precedences than byField & byPos i.e. when there is field or position based override applied to the target type, that gets the percedence. If there is no such overrides, all the occurrences of this type uses the Gen provided by this override.

byField :: forall s (field :: Symbol) t. (KnownSymbol field, Typeable s, Typeable t, FromEither (ValidateSel s (Rep s) field t)) => Gen t -> GenMap -> GenMap Source #

byField is used to override the Gen for type t of field named field in type s . This has higher precedences than byType and byPos

byPos :: forall s (pos :: Nat) t. (KnownNat pos, Typeable s, Typeable t, FromEither (ValidatePos s (Rep s) pos 1 t)) => Gen t -> GenMap -> GenMap Source #

byPos is used to override the Gen for type t at positon pos in type s . This has higher precedences than byType and lower precedence thab byField

data GenList (or :: [*]) where Source #

Hetrogenous List of Gen

Constructors

GNil :: GenList '[] 
(:&) :: Gen x -> GenList xs -> GenList (x ': xs) 

type GenMap = TypeRepMap Gen Source #

Map to hold type-based and field-based overrides of Gen