-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Generic random generators
--   
--   For more information
--   
--   <ul>
--   <li><a>Generic.Random.Tutorial</a></li>
--   
--   <li><a>http://blog.poisson.chat/posts/2018-01-05-generic-random-tour.html</a></li>
--   
--   <li><a>https://byorgey.wordpress.com/2016/09/20/the-generic-random-library-part-1-simple-generic-arbitrary-instances/</a></li>
--   </ul>
@package generic-random
@version 1.1.0.2

module Generic.Random.Internal.Generic

-- | Pick a constructor with a given distribution, and fill its fields with
--   recursive calls to <a>arbitrary</a>.
--   
--   <h3>Example</h3>
--   
--   <pre>
--   genericArbitrary (2 % 3 % 5 % ()) :: Gen a
--   </pre>
--   
--   Picks the first constructor with probability <tt>2/10</tt>, the second
--   with probability <tt>3/10</tt>, the third with probability
--   <tt>5/10</tt>.
genericArbitrary :: (GArbitrary UnsizedOpts a) => Weights a -> Gen a

-- | Pick every constructor with equal probability. Equivalent to
--   <tt><a>genericArbitrary</a> <a>uniform</a></tt>.
--   
--   <pre>
--   genericArbitraryU :: Gen a
--   </pre>
genericArbitraryU :: (GArbitrary UnsizedOpts a, GUniformWeight a) => Gen a

-- | <a>arbitrary</a> for types with one constructor. Equivalent to
--   <a>genericArbitraryU</a>, with a stricter type.
--   
--   <pre>
--   genericArbitrarySingle :: Gen a
--   </pre>
genericArbitrarySingle :: (GArbitrary UnsizedOpts a, Weights_ (Rep a) ~ L c0) => Gen a

-- | Decrease size at every recursive call, but don't do anything different
--   at size 0.
--   
--   <pre>
--   genericArbitraryRec (7 % 11 % 13 % ()) :: Gen a
--   </pre>
genericArbitraryRec :: (GArbitrary SizedOpts a) => Weights a -> Gen a

-- | <a>genericArbitrary</a> with explicit generators.
--   
--   <h3>Example</h3>
--   
--   <pre>
--   genericArbitraryG customGens (17 % 19 % ())
--   </pre>
--   
--   where, for example to override generators for <a>String</a> and
--   <a>Int</a> fields,
--   
--   <pre>
--   customGens :: <a>GenList</a> '[String, Int]
--   customGens =
--     (filter (/= '\NUL') <a>&lt;$&gt;</a> arbitrary) <a>:@</a>
--     (getNonNegative <a>&lt;$&gt;</a> arbitrary) <a>:@</a>
--     <a>Nil</a>
--   </pre>
--   
--   <h3>Note on multiple matches</h3>
--   
--   If the list contains multiple matching types for a field <tt>x</tt> of
--   type <tt>a</tt> (i.e., either <tt>a</tt> or <tt><a>Field</a> "x"
--   a</tt>), the generator for the first match will be picked.
genericArbitraryG :: (GArbitrary (SetGens g UnsizedOpts) a) => GenList g -> Weights a -> Gen a

-- | <a>genericArbitraryU</a> with explicit generators. See also
--   <a>genericArbitraryG</a>.
genericArbitraryUG :: (GArbitrary (SetGens g UnsizedOpts) a, GUniformWeight a) => GenList g -> Gen a

-- | <a>genericArbitrarySingle</a> with explicit generators. See also
--   <a>genericArbitraryG</a>.
genericArbitrarySingleG :: (GArbitrary (SetGens g UnsizedOpts) a, Weights_ (Rep a) ~ L c0) => GenList g -> Gen a

-- | <a>genericArbitraryRec</a> with explicit generators. See also
--   <a>genericArbitraryG</a>.
genericArbitraryRecG :: (GArbitrary (SetGens g SizedOpts) a) => GenList g -> Weights a -> Gen a

-- | General generic generator with custom options.
genericArbitraryWith :: (GArbitrary opts a) => opts -> Weights a -> Gen a
data a (:|) b
N :: a -> Int -> b -> (:|) a b
data L (c :: Symbol)
L :: L

-- | Trees of weights assigned to constructors of type <tt>a</tt>, rescaled
--   to obtain a probability distribution.
--   
--   Two ways of constructing them.
--   
--   <pre>
--   (x1 <a>%</a> x2 <a>%</a> ... <a>%</a> xn <a>%</a> ()) :: <a>Weights</a> a
--   <a>uniform</a> :: <a>Weights</a> a
--   </pre>
--   
--   Using <tt>(<a>%</a>)</tt>, there must be exactly as many weights as
--   there are constructors.
--   
--   <a>uniform</a> is equivalent to <tt>(1 <a>%</a> ... <a>%</a> 1
--   <a>%</a> ())</tt> (automatically fills out the right number of 1s).
data Weights a
Weights :: (Weights_ (Rep a)) -> Int -> Weights a

-- | Type of a single weight, tagged with the name of the associated
--   constructor for additional compile-time checking.
--   
--   <pre>
--   ((9 :: <a>W</a> "Leaf") <a>%</a> (8 :: <a>W</a> "Node") <a>%</a> ())
--   </pre>
newtype W (c :: Symbol)
W :: Int -> W

-- | A smart constructor to specify a custom distribution. It can be
--   omitted for the <a>%</a> operator is overloaded to insert it.
weights :: (Weights_ (Rep a), Int, ()) -> Weights a

-- | Uniform distribution.
uniform :: UniformWeight_ (Rep a) => Weights a
class WeightBuilder' w

-- | A binary constructor for building up trees of weights.
(%) :: WeightBuilder' w => W (First' w) -> Prec' w -> w
class WeightBuilder a where {
    type family Prec a r;
}
(%.) :: WeightBuilder a => W (First a) -> Prec a r -> (a, Int, r)
class UniformWeight a
uniformWeight :: UniformWeight a => (a, Int)
class UniformWeight (Weights_ f) => UniformWeight_ f

-- | Derived uniform distribution of constructors for <tt>a</tt>.
class UniformWeight_ (Rep a) => GUniformWeight a

-- | Type-level options for <a>GArbitrary</a>.
newtype Options (s :: Sizing) (g :: [Type])
Options :: GenList g -> Options
[_generators] :: Options -> GenList g
unsizedOpts :: UnsizedOpts
sizedOpts :: SizedOpts

-- | Whether to decrease the size parameter before generating fields.
data Sizing
Sized :: Sizing
Unsized :: Sizing
type UnsizedOpts = (Options  'Unsized '[] :: Type)
type SizedOpts = (Options  'Sized '[] :: Type)
proxySizing :: opts -> Proxy (SizingOf opts)
setSized :: Options s g -> Options  'Sized g
setUnsized :: Options s g -> Options  'Unsized g

-- | Heterogeneous list of generators.
data GenList (g :: [Type])
[Nil] :: GenList '[]
[:@] :: Gen a -> GenList g -> GenList (a : g)
class HasGenerators opts
generators :: HasGenerators opts => opts -> GenList (GeneratorsOf opts)
setGenerators :: GenList g -> Options s g0 -> Options s g

-- | A marker for a generator which overrides a specific field named
--   <tt>s</tt>.
--   
--   <i>Available only for <tt>base &gt;= 4.9</tt>.</i>
newtype Field (s :: Symbol) a
Field :: a -> Field a
[unField] :: Field a -> a

-- | <a>Field</a> constructor with the field name given via a proxy.
field :: proxy s -> a -> Field s a

-- | Generic Arbitrary
class GA opts f
ga :: GA opts f => opts -> Weights_ f -> Int -> Gen (f p)

-- | Generic Arbitrary
class (Generic a, GA opts (Rep a)) => GArbitrary opts a
gaSum' :: GASum opts f => opts -> Weights_ f -> Int -> Gen (f p)
class GASum opts f
gaSum :: GASum opts f => opts -> Int -> Weights_ f -> Gen (f p)
class GAProduct (s :: Sizing) opts f
gaProduct :: GAProduct s opts f => proxys s -> opts -> Gen (f p)
class GAProduct' opts f
gaProduct' :: GAProduct' opts f => opts -> Gen (f p)
class ArbitraryOr (g :: [Type]) (sel :: Maybe Symbol) a
arbitraryOr :: ArbitraryOr g sel a => proxy sel -> GenList g -> Gen a
newtype Weighted a
Weighted :: (Maybe (Int -> Gen a, Int)) -> Weighted a
liftGen :: Gen a -> Weighted a
instance GHC.Base.Functor Generic.Random.Internal.Generic.Weighted
instance GHC.Num.Num (Generic.Random.Internal.Generic.W c)
instance GHC.Base.Applicative Generic.Random.Internal.Generic.Weighted
instance GHC.Base.Alternative Generic.Random.Internal.Generic.Weighted
instance (Generic.Random.Internal.Generic.HasGenerators opts, Generic.Random.Internal.Generic.ArbitraryOr (Generic.Random.Internal.Generic.GeneratorsOf opts) (Generic.Random.Internal.Generic.SelectorName d) c) => Generic.Random.Internal.Generic.GAProduct' opts (GHC.Generics.S1 d (GHC.Generics.K1 i c))
instance Generic.Random.Internal.Generic.ArbitraryOr (a : g) sel a
instance Generic.Random.Internal.Generic.ArbitraryOr g sel a => Generic.Random.Internal.Generic.ArbitraryOr (b : g) sel a
instance Test.QuickCheck.Arbitrary.Arbitrary a => Generic.Random.Internal.Generic.ArbitraryOr '[] sel a
instance Generic.Random.Internal.Generic.ArbitraryOr (Generic.Random.Internal.Generic.Field n a : g) ('GHC.Base.Just n) a
instance (Generic.Random.Internal.Generic.GAProduct' opts f, GHC.TypeNats.KnownNat (Generic.Random.Internal.Generic.Arity f)) => Generic.Random.Internal.Generic.GAProduct 'Generic.Random.Internal.Generic.Sized opts f
instance Generic.Random.Internal.Generic.GAProduct' opts f => Generic.Random.Internal.Generic.GAProduct 'Generic.Random.Internal.Generic.Unsized opts f
instance Generic.Random.Internal.Generic.GAProduct' opts GHC.Generics.U1
instance (Generic.Random.Internal.Generic.GAProduct' opts f, Generic.Random.Internal.Generic.GAProduct' opts g) => Generic.Random.Internal.Generic.GAProduct' opts (f GHC.Generics.:*: g)
instance Generic.Random.Internal.Generic.GAProduct (Generic.Random.Internal.Generic.SizingOf opts) opts f => Generic.Random.Internal.Generic.GA opts (GHC.Generics.M1 GHC.Generics.C c f)
instance Generic.Random.Internal.Generic.GAProduct (Generic.Random.Internal.Generic.SizingOf opts) opts f => Generic.Random.Internal.Generic.GASum opts (GHC.Generics.M1 i c f)
instance Generic.Random.Internal.Generic.GAProduct 'Generic.Random.Internal.Generic.Sized opts GHC.Generics.U1
instance (Generic.Random.Internal.Generic.GASum opts f, Generic.Random.Internal.Generic.GASum opts g) => Generic.Random.Internal.Generic.GA opts (f GHC.Generics.:+: g)
instance (Generic.Random.Internal.Generic.GASum opts f, Generic.Random.Internal.Generic.GASum opts g) => Generic.Random.Internal.Generic.GASum opts (f GHC.Generics.:+: g)
instance (GHC.Generics.Generic a, Generic.Random.Internal.Generic.GA opts (GHC.Generics.Rep a)) => Generic.Random.Internal.Generic.GArbitrary opts a
instance Generic.Random.Internal.Generic.GA opts f => Generic.Random.Internal.Generic.GA opts (GHC.Generics.M1 GHC.Generics.D c f)
instance Generic.Random.Internal.Generic.HasGenerators (Generic.Random.Internal.Generic.Options s g)
instance Generic.Random.Internal.Generic.UniformWeight_ (GHC.Generics.Rep a) => Generic.Random.Internal.Generic.GUniformWeight a
instance Generic.Random.Internal.Generic.UniformWeight (Generic.Random.Internal.Generic.Weights_ f) => Generic.Random.Internal.Generic.UniformWeight_ f
instance (Generic.Random.Internal.Generic.UniformWeight a, Generic.Random.Internal.Generic.UniformWeight b) => Generic.Random.Internal.Generic.UniformWeight (a Generic.Random.Internal.Generic.:| b)
instance Generic.Random.Internal.Generic.UniformWeight (Generic.Random.Internal.Generic.L c)
instance Generic.Random.Internal.Generic.UniformWeight ()
instance Generic.Random.Internal.Generic.WeightBuilder (Generic.Random.Internal.Generic.Weights_ (GHC.Generics.Rep a)) => Generic.Random.Internal.Generic.WeightBuilder' (Generic.Random.Internal.Generic.Weights a)
instance Generic.Random.Internal.Generic.WeightBuilder a => Generic.Random.Internal.Generic.WeightBuilder' (a, GHC.Types.Int, r)
instance Generic.Random.Internal.Generic.WeightBuilder a => Generic.Random.Internal.Generic.WeightBuilder (a Generic.Random.Internal.Generic.:| b)
instance Generic.Random.Internal.Generic.WeightBuilder (Generic.Random.Internal.Generic.L c)
instance Generic.Random.Internal.Generic.WeightBuilder ()

module Generic.Random.Internal.BaseCase

-- | Decrease size to ensure termination for recursive types, looking for
--   base cases once the size reaches 0.
--   
--   <pre>
--   genericArbitrary' (17 % 19 % 23 % ()) :: Gen a
--   </pre>
genericArbitrary' :: (GArbitrary SizedOpts a, BaseCase a) => Weights a -> Gen a

-- | Equivalent to <tt><a>genericArbitrary'</a> <a>uniform</a></tt>.
--   
--   <pre>
--   genericArbitraryU :: Gen a
--   </pre>
genericArbitraryU' :: (GArbitrary SizedOpts a, BaseCase a, GUniformWeight a) => Gen a

-- | Run the first generator if the size is positive. Run the second if the
--   size is zero.
--   
--   <pre>
--   defaultGen `withBaseCase` baseCaseGen
--   </pre>
withBaseCase :: Gen a -> Gen a -> Gen a

-- | Find a base case of type <tt>a</tt> with maximum depth <tt>z</tt>,
--   recursively using <a>BaseCaseSearch</a> instances to search deeper
--   levels.
--   
--   <tt>y</tt> is the depth of a base case, if found.
--   
--   <tt>e</tt> is the original type the search started with, that
--   <tt>a</tt> appears in. It is used for error reporting.
class BaseCaseSearch (a :: *) (z :: Nat) (y :: Maybe Nat) (e :: *)
baseCaseSearch :: BaseCaseSearch a z y e => prox y -> proxy '(z, e) -> IfM y Gen Proxy a
class BaseCaseSearching_ a z y
baseCaseSearching_ :: BaseCaseSearching_ a z y => proxy y -> proxy2 '(z, a) -> IfM y Gen Proxy a -> Gen a

-- | Progressively increase the depth bound for <a>BaseCaseSearch</a>.
class BaseCaseSearching a z
baseCaseSearching :: BaseCaseSearching a z => proxy '(z, a) -> Gen a

-- | Custom instances can override the default behavior.
class BaseCase a

-- | Generator of base cases.
baseCase :: BaseCase a => Gen a

-- | Overlappable
type (==) m n = IsEQ (CmpNat m n)
type Max m n = MaxOf (CmpNat m n) m n
type Min m n = MinOf (CmpNat m n) m n
class Alternative (IfM y Weighted Proxy) => GBCS (f :: k -> *) (z :: Nat) (y :: Maybe Nat) (e :: *)
gbcs :: GBCS f z y e => prox y -> proxy '(z, e) -> IfM y Weighted Proxy (f p)
class Alternative (IfM (yf ||? yg) Weighted Proxy) => GBCSSum f g z e yf yg
gbcsSum :: GBCSSum f g z e yf yg => prox '(yf, yg) -> proxy '(z, e) -> IfM yf Weighted Proxy (f p) -> IfM yg Weighted Proxy (g p) -> IfM (yf ||? yg) Weighted Proxy ((f :+: g) p)
class GBCSSumCompare f g z e o
gbcsSumCompare :: GBCSSumCompare f g z e o => proxy0 o -> proxy '(z, e) -> Weighted (f p) -> Weighted (g p) -> Weighted ((f :+: g) p)
class Alternative (IfM (yf &&? yg) Weighted Proxy) => GBCSProduct f g z e yf yg
gbcsProduct :: GBCSProduct f g z e yf yg => prox '(yf, yg) -> proxy '(z, e) -> IfM yf Weighted Proxy (f p) -> IfM yg Weighted Proxy (g p) -> IfM (yf &&? yg) Weighted Proxy ((f :*: g) p)
class IsMaybe b
ifMmap :: IsMaybe b => proxy b -> (c a -> c' a') -> (d a -> d' a') -> IfM b c d a -> IfM b c' d' a'
ifM :: IsMaybe b => proxy b -> c a -> d a -> IfM b c d a
class GBaseCaseSearch a z y e
gBaseCaseSearch :: GBaseCaseSearch a z y e => prox y -> proxy '(z, e) -> IfM y Gen Proxy a
instance Generic.Random.Internal.BaseCase.GBaseCaseSearch a z y e => Generic.Random.Internal.BaseCase.BaseCaseSearch a z y e
instance (GHC.Generics.Generic a, Generic.Random.Internal.BaseCase.GBCS (GHC.Generics.Rep a) z y e, Generic.Random.Internal.BaseCase.IsMaybe y) => Generic.Random.Internal.BaseCase.GBaseCaseSearch a z y e
instance forall t1 (t2 :: t1). Generic.Random.Internal.BaseCase.IsMaybe ('GHC.Base.Just t2)
instance Generic.Random.Internal.BaseCase.IsMaybe 'GHC.Base.Nothing
instance (Generic.Random.Internal.BaseCase.BaseCaseSearch c (z GHC.TypeNats.- 1) y e, (z Generic.Random.Internal.BaseCase.== 0) ~ 'GHC.Types.False, GHC.Base.Alternative (Generic.Random.Internal.BaseCase.IfM y Generic.Random.Internal.Generic.Weighted Data.Proxy.Proxy), Generic.Random.Internal.BaseCase.IsMaybe y) => Generic.Random.Internal.BaseCase.GBCS (GHC.Generics.K1 i c) z y e
instance forall k (f :: k -> *) (g :: k -> *) (z :: GHC.Types.Nat) e (yf :: GHC.Base.Maybe GHC.Types.Nat) (yg :: GHC.Base.Maybe GHC.Types.Nat) (y :: GHC.Base.Maybe GHC.Types.Nat). (Generic.Random.Internal.BaseCase.GBCSProduct f g z e yf yg, Generic.Random.Internal.BaseCase.GBCS f z yf e, Generic.Random.Internal.BaseCase.GBCS g z yg e, y ~ (yf Generic.Random.Internal.BaseCase.&&? yg)) => Generic.Random.Internal.BaseCase.GBCS (f GHC.Generics.:*: g) z y e
instance forall k1 k2 k3 (yf :: GHC.Base.Maybe GHC.Types.Nat) (yg :: GHC.Base.Maybe GHC.Types.Nat) (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1). (yf Generic.Random.Internal.BaseCase.&&? yg) ~ 'GHC.Base.Nothing => Generic.Random.Internal.BaseCase.GBCSProduct f g z e yf yg
instance forall k1 k2 k3 (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) (m :: GHC.Types.Nat) (n :: GHC.Types.Nat). Generic.Random.Internal.BaseCase.GBCSProduct f g z e ('GHC.Base.Just m) ('GHC.Base.Just n)
instance forall k1 k2 k3 (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) (m :: GHC.Types.Nat) (n :: GHC.Types.Nat). Generic.Random.Internal.BaseCase.GBCSSumCompare f g z e (GHC.TypeNats.CmpNat m n) => Generic.Random.Internal.BaseCase.GBCSSum f g z e ('GHC.Base.Just m) ('GHC.Base.Just n)
instance forall k1 k2 k3 (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1). Generic.Random.Internal.BaseCase.GBCSSumCompare f g z e 'GHC.Types.EQ
instance forall k1 k2 k3 (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1). Generic.Random.Internal.BaseCase.GBCSSumCompare f g z e 'GHC.Types.LT
instance forall k1 k2 k3 (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1). Generic.Random.Internal.BaseCase.GBCSSumCompare f g z e 'GHC.Types.GT
instance forall k (f :: k -> *) (g :: k -> *) (z :: GHC.Types.Nat) e (yf :: GHC.Base.Maybe GHC.Types.Nat) (yg :: GHC.Base.Maybe GHC.Types.Nat) (y :: GHC.Base.Maybe GHC.Types.Nat). (Generic.Random.Internal.BaseCase.GBCSSum f g z e yf yg, Generic.Random.Internal.BaseCase.GBCS f z yf e, Generic.Random.Internal.BaseCase.GBCS g z yg e, y ~ (yf Generic.Random.Internal.BaseCase.||? yg)) => Generic.Random.Internal.BaseCase.GBCS (f GHC.Generics.:+: g) z y e
instance forall k1 k2 k3 (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1). Generic.Random.Internal.BaseCase.GBCSSum f g z e 'GHC.Base.Nothing 'GHC.Base.Nothing
instance forall k1 k2 k3 (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) (m :: GHC.Types.Nat). Generic.Random.Internal.BaseCase.GBCSSum f g z e ('GHC.Base.Just m) 'GHC.Base.Nothing
instance forall k1 k2 k3 (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) (n :: GHC.Types.Nat). Generic.Random.Internal.BaseCase.GBCSSum f g z e 'GHC.Base.Nothing ('GHC.Base.Just n)
instance forall k (f :: k -> *) (z :: GHC.Types.Nat) (y :: GHC.Base.Maybe GHC.Types.Nat) e i (c :: GHC.Generics.Meta). Generic.Random.Internal.BaseCase.GBCS f z y e => Generic.Random.Internal.BaseCase.GBCS (GHC.Generics.M1 i c f) z y e
instance y ~ 'GHC.Base.Nothing => Generic.Random.Internal.BaseCase.GBCS (GHC.Generics.K1 i c) 0 y e
instance y ~ 'GHC.Base.Just 0 => Generic.Random.Internal.BaseCase.GBCS GHC.Generics.U1 z y e
instance forall k (f :: k -> *) e (y :: GHC.Base.Maybe GHC.Types.Nat) (z :: GHC.Types.Nat). ((TypeError ...), GHC.Base.Alternative (Generic.Random.Internal.BaseCase.IfM y Generic.Random.Internal.Generic.Weighted Data.Proxy.Proxy)) => Generic.Random.Internal.BaseCase.GBCS f z y e
instance y ~ 'GHC.Base.Just 0 => Generic.Random.Internal.BaseCase.BaseCaseSearch GHC.Types.Char z y e
instance y ~ 'GHC.Base.Just 0 => Generic.Random.Internal.BaseCase.BaseCaseSearch GHC.Types.Int z y e
instance y ~ 'GHC.Base.Just 0 => Generic.Random.Internal.BaseCase.BaseCaseSearch GHC.Integer.Type.Integer z y e
instance y ~ 'GHC.Base.Just 0 => Generic.Random.Internal.BaseCase.BaseCaseSearch GHC.Types.Float z y e
instance y ~ 'GHC.Base.Just 0 => Generic.Random.Internal.BaseCase.BaseCaseSearch GHC.Types.Double z y e
instance y ~ 'GHC.Base.Just 0 => Generic.Random.Internal.BaseCase.BaseCaseSearch GHC.Types.Word z y e
instance y ~ 'GHC.Base.Just 0 => Generic.Random.Internal.BaseCase.BaseCaseSearch () z y e
instance y ~ 'GHC.Base.Just 0 => Generic.Random.Internal.BaseCase.BaseCaseSearch GHC.Types.Bool z y e
instance y ~ 'GHC.Base.Just 0 => Generic.Random.Internal.BaseCase.BaseCaseSearch [a] z y e
instance y ~ 'GHC.Base.Just 0 => Generic.Random.Internal.BaseCase.BaseCaseSearch GHC.Types.Ordering z y e
instance (Generic.Random.Internal.BaseCase.BaseCaseSearch a z y a, Generic.Random.Internal.BaseCase.BaseCaseSearching_ a z y) => Generic.Random.Internal.BaseCase.BaseCaseSearching a z
instance forall t k a (z :: k) (m :: t). Generic.Random.Internal.BaseCase.BaseCaseSearching_ a z ('GHC.Base.Just m)
instance Generic.Random.Internal.BaseCase.BaseCaseSearching a (z GHC.TypeNats.+ 1) => Generic.Random.Internal.BaseCase.BaseCaseSearching_ a z 'GHC.Base.Nothing
instance Generic.Random.Internal.BaseCase.BaseCaseSearching a 0 => Generic.Random.Internal.BaseCase.BaseCase a


-- | Simple <a>GHC.Generics</a>-based <tt>arbitrary</tt> generators.
--   
--   For more information:
--   
--   <ul>
--   <li><a>Generic.Random.Tutorial</a></li>
--   
--   <li><a>http://blog.poisson.chat/posts/2018-01-05-generic-random-tour.html</a></li>
--   
--   <li><a>https://byorgey.wordpress.com/2016/09/20/the-generic-random-library-part-1-simple-generic-arbitrary-instances/</a></li>
--   </ul>
module Generic.Random

-- | Pick a constructor with a given distribution, and fill its fields with
--   recursive calls to <a>arbitrary</a>.
--   
--   <h3>Example</h3>
--   
--   <pre>
--   genericArbitrary (2 % 3 % 5 % ()) :: Gen a
--   </pre>
--   
--   Picks the first constructor with probability <tt>2/10</tt>, the second
--   with probability <tt>3/10</tt>, the third with probability
--   <tt>5/10</tt>.
genericArbitrary :: (GArbitrary UnsizedOpts a) => Weights a -> Gen a

-- | Pick every constructor with equal probability. Equivalent to
--   <tt><a>genericArbitrary</a> <a>uniform</a></tt>.
--   
--   <pre>
--   genericArbitraryU :: Gen a
--   </pre>
genericArbitraryU :: (GArbitrary UnsizedOpts a, GUniformWeight a) => Gen a

-- | <a>arbitrary</a> for types with one constructor. Equivalent to
--   <a>genericArbitraryU</a>, with a stricter type.
--   
--   <pre>
--   genericArbitrarySingle :: Gen a
--   </pre>
genericArbitrarySingle :: (GArbitrary UnsizedOpts a, Weights_ (Rep a) ~ L c0) => Gen a

-- | Decrease size at every recursive call, but don't do anything different
--   at size 0.
--   
--   <pre>
--   genericArbitraryRec (7 % 11 % 13 % ()) :: Gen a
--   </pre>
genericArbitraryRec :: (GArbitrary SizedOpts a) => Weights a -> Gen a

-- | Decrease size to ensure termination for recursive types, looking for
--   base cases once the size reaches 0.
--   
--   <pre>
--   genericArbitrary' (17 % 19 % 23 % ()) :: Gen a
--   </pre>
genericArbitrary' :: (GArbitrary SizedOpts a, BaseCase a) => Weights a -> Gen a

-- | Equivalent to <tt><a>genericArbitrary'</a> <a>uniform</a></tt>.
--   
--   <pre>
--   genericArbitraryU :: Gen a
--   </pre>
genericArbitraryU' :: (GArbitrary SizedOpts a, BaseCase a, GUniformWeight a) => Gen a

-- | <a>genericArbitrary</a> with explicit generators.
--   
--   <h3>Example</h3>
--   
--   <pre>
--   genericArbitraryG customGens (17 % 19 % ())
--   </pre>
--   
--   where, for example to override generators for <a>String</a> and
--   <a>Int</a> fields,
--   
--   <pre>
--   customGens :: <a>GenList</a> '[String, Int]
--   customGens =
--     (filter (/= '\NUL') <a>&lt;$&gt;</a> arbitrary) <a>:@</a>
--     (getNonNegative <a>&lt;$&gt;</a> arbitrary) <a>:@</a>
--     <a>Nil</a>
--   </pre>
--   
--   <h3>Note on multiple matches</h3>
--   
--   If the list contains multiple matching types for a field <tt>x</tt> of
--   type <tt>a</tt> (i.e., either <tt>a</tt> or <tt><a>Field</a> "x"
--   a</tt>), the generator for the first match will be picked.
genericArbitraryG :: (GArbitrary (SetGens g UnsizedOpts) a) => GenList g -> Weights a -> Gen a

-- | <a>genericArbitraryU</a> with explicit generators. See also
--   <a>genericArbitraryG</a>.
genericArbitraryUG :: (GArbitrary (SetGens g UnsizedOpts) a, GUniformWeight a) => GenList g -> Gen a

-- | <a>genericArbitrarySingle</a> with explicit generators. See also
--   <a>genericArbitraryG</a>.
genericArbitrarySingleG :: (GArbitrary (SetGens g UnsizedOpts) a, Weights_ (Rep a) ~ L c0) => GenList g -> Gen a

-- | <a>genericArbitraryRec</a> with explicit generators. See also
--   <a>genericArbitraryG</a>.
genericArbitraryRecG :: (GArbitrary (SetGens g SizedOpts) a) => GenList g -> Weights a -> Gen a

-- | General generic generator with custom options.
genericArbitraryWith :: (GArbitrary opts a) => opts -> Weights a -> Gen a

-- | Run the first generator if the size is positive. Run the second if the
--   size is zero.
--   
--   <pre>
--   defaultGen `withBaseCase` baseCaseGen
--   </pre>
withBaseCase :: Gen a -> Gen a -> Gen a

-- | Custom instances can override the default behavior.
class BaseCase a

-- | Generator of base cases.
baseCase :: BaseCase a => Gen a

-- | Trees of weights assigned to constructors of type <tt>a</tt>, rescaled
--   to obtain a probability distribution.
--   
--   Two ways of constructing them.
--   
--   <pre>
--   (x1 <a>%</a> x2 <a>%</a> ... <a>%</a> xn <a>%</a> ()) :: <a>Weights</a> a
--   <a>uniform</a> :: <a>Weights</a> a
--   </pre>
--   
--   Using <tt>(<a>%</a>)</tt>, there must be exactly as many weights as
--   there are constructors.
--   
--   <a>uniform</a> is equivalent to <tt>(1 <a>%</a> ... <a>%</a> 1
--   <a>%</a> ())</tt> (automatically fills out the right number of 1s).
data Weights a

-- | Type of a single weight, tagged with the name of the associated
--   constructor for additional compile-time checking.
--   
--   <pre>
--   ((9 :: <a>W</a> "Leaf") <a>%</a> (8 :: <a>W</a> "Node") <a>%</a> ())
--   </pre>
data W (c :: Symbol)

-- | A binary constructor for building up trees of weights.
(%) :: WeightBuilder' w => W (First' w) -> Prec' w -> w
infixr 1 %

-- | Uniform distribution.
uniform :: UniformWeight_ (Rep a) => Weights a

-- | Type-level options for <a>GArbitrary</a>.
data Options (s :: Sizing) (g :: [Type])
type SizedOpts = (Options  'Sized '[] :: Type)
sizedOpts :: SizedOpts
type UnsizedOpts = (Options  'Unsized '[] :: Type)
unsizedOpts :: UnsizedOpts

-- | Whether to decrease the size parameter before generating fields.
data Sizing
Sized :: Sizing
Unsized :: Sizing
setSized :: Options s g -> Options  'Sized g
setUnsized :: Options s g -> Options  'Unsized g

-- | Heterogeneous list of generators.
data GenList (g :: [Type])
[Nil] :: GenList '[]
[:@] :: Gen a -> GenList g -> GenList (a : g)

-- | A marker for a generator which overrides a specific field named
--   <tt>s</tt>.
--   
--   <i>Available only for <tt>base &gt;= 4.9</tt>.</i>
newtype Field (s :: Symbol) a
Field :: a -> Field a
[unField] :: Field a -> a

-- | <a>Field</a> constructor with the field name given via a proxy.
field :: proxy s -> a -> Field s a
setGenerators :: GenList g -> Options s g0 -> Options s g

-- | Generic Arbitrary
class (Generic a, GA opts (Rep a)) => GArbitrary opts a

-- | Derived uniform distribution of constructors for <tt>a</tt>.
class UniformWeight_ (Rep a) => GUniformWeight a


-- | Reexport of <a>Generic.Random</a>, for backwards-compatibility.

-- | <i>Deprecated: Use Generic.Random instead</i>
module Generic.Random.Generic


-- | Generic implementations of <a>QuickCheck</a>'s <tt>arbitrary</tt>.
--   
--   <h2>Example</h2>
--   
--   Define your type.
--   
--   <pre>
--   data Tree a = Leaf a | Node (Tree a) (Tree a)
--     deriving <a>Generic</a>
--   </pre>
--   
--   Pick an <tt>arbitrary</tt> implementation, specifying the required
--   distribution of data constructors.
--   
--   <pre>
--   instance Arbitrary a =&gt; Arbitrary (Tree a) where
--     arbitrary = <a>genericArbitrary</a> (8 <a>%</a> 9 <a>%</a> ())
--   </pre>
--   
--   <tt>arbitrary :: <tt>Gen</tt> (Tree a)</tt> picks a <tt>Leaf</tt> with
--   probability 9/17, or a <tt>Node</tt> with probability 8/17, and
--   recursively fills their fields with <tt>arbitrary</tt>.
--   
--   For <tt>Tree</tt>, <a>genericArbitrary</a> produces code equivalent to
--   the following:
--   
--   <pre>
--   <a>genericArbitrary</a> :: Arbitrary a =&gt; <a>Weights</a> (Tree a) -&gt; Gen (Tree a)
--   <a>genericArbitrary</a> (x <a>%</a> y <a>%</a> ()) =
--     frequency
--       [ (x, Leaf &lt;$&gt; arbitrary)
--       , (y, Node &lt;$&gt; arbitrary &lt;*&gt; arbitrary)
--       ]
--   </pre>
--   
--   <h2>Distribution of constructors</h2>
--   
--   The distribution of constructors can be specified as a special list of
--   <i>weights</i> in the same order as the data type definition. This
--   assigns to each constructor a probability proportional to its weight;
--   in other words, <tt>p_C = weight_C / sumOfWeights</tt>.
--   
--   The list of weights is built up with the <tt>(<a>%</a>)</tt> operator
--   as a cons, and using the unit <tt>()</tt> as the empty list, in the
--   order corresponding to the data type definition. The uniform
--   distribution can be obtained with <a>uniform</a>.
--   
--   <h3>Uniform distribution</h3>
--   
--   You can specify the uniform distribution (all weights equal) with
--   <a>uniform</a>. (<a>genericArbitraryU</a> is available as a shorthand
--   for <tt><a>genericArbitrary</a> <a>uniform</a></tt>.)
--   
--   Note that for many recursive types, a uniform distribution tends to
--   produce big or even infinite values.
--   
--   <h3>Typed weights</h3>
--   
--   <i>GHC 8.0.1 and above only (base ≥ 4.9).</i>
--   
--   The weights actually have type <tt><a>W</a> "ConstructorName"</tt>
--   (just a newtype around <a>Int</a>), so that you can annotate a weight
--   with its corresponding constructor, and it will be checked that you
--   got the order right.
--   
--   This will type-check.
--   
--   <pre>
--   ((x :: <a>W</a> "Leaf") <a>%</a> (y :: <a>W</a> "Node") <a>%</a> ()) :: <a>Weights</a> (Tree a)
--   (x <a>%</a> (y :: <a>W</a> "Node") <a>%</a> ()) :: <a>Weights</a> (Tree a)
--   </pre>
--   
--   This will not.
--   
--   <pre>
--   ((x :: <a>W</a> "Node") <a>%</a> y <a>%</a> ()) :: <a>Weights</a> (Tree a)
--   -- Requires an order of constructors different from the definition of the <tt>Tree</tt> type.
--   
--   (x <a>%</a> y <a>%</a> z <a>%</a> ()) :: <a>Weights</a> (Tree a)
--   -- Doesn't have the right number of weights.
--   </pre>
--   
--   <h2>Ensuring termination</h2>
--   
--   As mentioned earlier, one must be careful with recursive types to
--   avoid producing extremely large values.
--   
--   The alternative generator <a>genericArbitrary'</a> implements a simple
--   strategy to keep values at reasonable sizes: the size parameter of
--   <tt>Gen</tt> is divided among the fields of the chosen constructor.
--   When it reaches zero, the generator selects a small term of the given
--   type. This generally ensures that the number of constructors remains
--   close to the initial size parameter passed to <tt>Gen</tt>.
--   
--   <pre>
--   <a>genericArbitrary'</a> (x1 <a>%</a> ... <a>%</a> xn <a>%</a> ())
--   </pre>
--   
--   Here is an example with nullary constructors:
--   
--   <pre>
--   data Bush = Leaf1 | Leaf2 | Node3 Bush Bush Bush
--     deriving Generic
--   
--   instance Arbitrary Bush where
--     arbitrary = <a>genericArbitrary'</a> (1 <a>%</a> 2 <a>%</a> 3 <a>%</a> ())
--   </pre>
--   
--   Here, <a>genericArbitrary'</a> is equivalent to:
--   
--   <pre>
--   <a>genericArbitrary'</a> :: <a>Weights</a> Bush -&gt; Gen Bush
--   <a>genericArbitrary'</a> (x <a>%</a> y <a>%</a> z <a>%</a> ()) =
--     sized $ \n -&gt;
--       if n == 0 then
--         -- If the size parameter is zero, only nullary alternatives are kept.
--         elements [Leaf1, Leaf2]
--       else
--         frequency
--           [ (x, return Leaf1)
--           , (y, return Leaf2)
--           , (z, resize (n `div` 3) node)  -- 3 because Node3 is 3-ary
--           ]
--     where
--       node = Node3 &lt;$&gt; arbitrary &lt;*&gt; arbitrary &lt;*&gt; arbitrary
--   </pre>
--   
--   If we want to generate a value of type <tt>Tree ()</tt>, there is a
--   value of depth 1 that we can use to end recursion: <tt>Leaf ()</tt>.
--   
--   <pre>
--   <a>genericArbitrary'</a> :: <a>Weights</a> (Tree ()) -&gt; Gen (Tree ())
--   <a>genericArbitrary'</a> (x <a>%</a> y <a>%</a> ()) =
--     sized $ \n -&gt;
--       if n == 0 then
--         return (Leaf ())
--       else
--         frequency
--           [ (x, Leaf &lt;$&gt; arbitrary)
--           , (y, resize (n `div` 2) $ Node &lt;$&gt; arbitrary &lt;*&gt; arbitrary)
--           ]
--   </pre>
--   
--   Because the argument of <tt>Tree</tt> must be inspected in order to
--   discover values of type <tt>Tree ()</tt>, we incur some extra
--   constraints if we want polymorphism.
--   
--   <pre>
--   {-# LANGUAGE FlexibleContexts, UndecidableInstances #-}
--   
--   instance (Arbitrary a, BaseCase (Tree a))
--     =&gt; Arbitrary (Tree a) where
--     arbitrary = <a>genericArbitrary'</a> (1 <a>%</a> 2 <a>%</a> ())
--   </pre>
--   
--   By default, the <a>BaseCase</a> type class looks for all values of
--   minimal depth (constructors have depth <tt>1 + max(0, depths of
--   fields)</tt>).
--   
--   This can easily be overriden by declaring a specialized
--   <a>BaseCase</a> instance, such as this one:
--   
--   <pre>
--   instance Arbitrary a =&gt; <a>BaseCase</a> (Tree a) where
--     <a>baseCase</a> = oneof [leaf, simpleNode]
--       where
--         leaf = Leaf &lt;$&gt; arbitrary
--         simpleNode = Node &lt;$&gt; leaf &lt;*&gt; leaf
--   </pre>
--   
--   An alternative base case can also be specified directly in the
--   <tt>arbitrary</tt> definition with the <a>withBaseCase</a> combinator.
--   
--   <a>genericArbitraryRec</a> is a variant of <a>genericArbitrary'</a>
--   with no base case.
--   
--   <pre>
--   instance Arbitrary Bush where
--     arbitrary =
--       <a>genericArbitraryRec</a> (1 <a>%</a> 2 <a>%</a> 3 <a>%</a> ())
--         `withBaseCase` return Leaf1
--   </pre>
--   
--   <h2>Custom generators for some fields</h2>
--   
--   Sometimes, a few fields may need custom generators instead of
--   <tt>arbitrary</tt>. For example, imagine here that String is meant to
--   represent alphanumerical strings only, and that IDs are meant to be
--   nonnegative, whereas balances can have any sign.
--   
--   <pre>
--   data User = User {
--     userName :: String,
--     userId :: Int,
--     userBalance :: Int
--     } deriving <a>Generic</a>
--   </pre>
--   
--   <ul>
--   <li><tt><tt>Arbitrary</tt> String</tt> may generate any unicode
--   characters, alphanumeric or not;</li>
--   <li><tt><tt>Arbitrary</tt> Int</tt> may generate negative values;</li>
--   <li>using <tt>newtype</tt> wrappers or passing generators explicitly
--   to properties may be impractical (the maintenance overhead can be high
--   because the types are big or change often).</li>
--   </ul>
--   
--   Using generic-random, the alternative is to declare a (heterogeneous)
--   list of generators to be used when generating certain fields...
--   
--   <pre>
--   customGens :: <a>GenList</a> '[<a>Field</a> "userId" Int, String]
--   customGens =
--     (<a>Field</a> . <tt>getNonNegative</tt> &lt;$&gt; arbitrary) <a>:@</a>
--     (<tt>listOf</tt> (<tt>elements</tt> (filter isAlphaNum [minBound .. maxBound]))) <a>:@</a>
--     <a>Nil</a>
--   </pre>
--   
--   And to use the <a>genericArbitraryG</a> and variants that accept those
--   explicit generators.
--   
--   <ul>
--   <li>All <tt>String</tt> fields will use the provided generator of
--   alphanumeric strings;</li>
--   <li>the field <tt>"userId"</tt> of type <tt>Int</tt> will use the
--   generator of nonnegative integers (the <a>Field</a> type is
--   special);</li>
--   <li>everything else defaults to <tt>arbitrary</tt>.</li>
--   </ul>
--   
--   <pre>
--   instance Arbitrary User where
--     arbitrary = <a>genericArbitrarySingleG</a> customGens
--   </pre>
module Generic.Random.Tutorial
