| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Generic.Random.Internal.BaseCase
Synopsis
- genericArbitrary' :: (GArbitrary SizedOptsDef a, BaseCase a) => Weights a -> Gen a
- genericArbitraryU' :: (GArbitrary SizedOptsDef a, BaseCase a, GUniformWeight a) => Gen a
- withBaseCase :: Gen a -> Gen a -> Gen a
- class BaseCaseSearch (a :: *) (z :: Nat) (y :: Maybe Nat) (e :: *) where
- class BaseCaseSearching_ a z y where
- class BaseCaseSearching a z where
- class BaseCase a where
- type family IfM (b :: Maybe t) (c :: k) (d :: k) :: k
- type (==) m n = IsEQ (CmpNat m n)
- type family IsEQ (e :: Ordering) :: Bool
- type family (b :: Maybe Nat) ||? (c :: Maybe Nat) :: Maybe Nat
- type family (b :: Maybe Nat) &&? (c :: Maybe Nat) :: Maybe Nat
- type Max m n = MaxOf (CmpNat m n) m n
- type family MaxOf (e :: Ordering) (m :: k) (n :: k) :: k
- type Min m n = MinOf (CmpNat m n) m n
- type family MinOf (e :: Ordering) (m :: k) (n :: k) :: k
- class Alternative (IfM y Weighted Proxy) => GBCS (f :: k -> *) (z :: Nat) (y :: Maybe Nat) (e :: *) where
- class Alternative (IfM (yf ||? yg) Weighted Proxy) => GBCSSum f g z e yf yg where
- class GBCSSumCompare f g z e o where
- class Alternative (IfM (yf &&? yg) Weighted Proxy) => GBCSProduct f g z e yf yg where
- class IsMaybe b where
- class GBaseCaseSearch a z y e where
Documentation
Arguments
| :: (GArbitrary SizedOptsDef a, BaseCase a) | |
| => Weights a | List of weights for every constructor |
| -> Gen a |
Decrease size to ensure termination for recursive types, looking for base cases once the size reaches 0.
genericArbitrary' (17 % 19 % 23 % ()) :: Gen a
N.B.: This replaces fields of type [t] with .listOf' arbitrary
genericArbitraryU' :: (GArbitrary SizedOptsDef a, BaseCase a, GUniformWeight a) => Gen a #
Equivalent to .genericArbitrary' uniform
genericArbitraryU :: Gen a
N.B.: This replaces fields of type [t] with .listOf' arbitrary
withBaseCase :: Gen a -> Gen a -> Gen a #
Run the first generator if the size is positive. Run the second if the size is zero.
defaultGen `withBaseCase` baseCaseGen
class BaseCaseSearch (a :: *) (z :: Nat) (y :: Maybe Nat) (e :: *) where #
Find a base case of type a with maximum depth z,
recursively using BaseCaseSearch instances to search deeper levels.
y is the depth of a base case, if found.
e is the original type the search started with, that a appears in.
It is used for error reporting.
Minimal complete definition
Methods
baseCaseSearch :: prox y -> proxy '(z, e) -> IfM y Gen Proxy a #
Instances
class BaseCaseSearching_ a z y where #
Minimal complete definition
Instances
| BaseCaseSearching a (z + 1) => BaseCaseSearching_ a (z :: Nat) (Nothing :: Maybe t) # | |
Defined in Generic.Random.Internal.BaseCase | |
| BaseCaseSearching_ a (z :: k) (Just m :: Maybe t) # | |
Defined in Generic.Random.Internal.BaseCase | |
class BaseCaseSearching a z where #
Progressively increase the depth bound for BaseCaseSearch.
Minimal complete definition
Methods
baseCaseSearching :: proxy '(z, a) -> Gen a #
Instances
| (BaseCaseSearch a z y a, BaseCaseSearching_ a z y) => BaseCaseSearching a (z :: Nat) # | |
Defined in Generic.Random.Internal.BaseCase Methods baseCaseSearching :: proxy (z, a) -> Gen a # | |
Custom instances can override the default behavior.
Minimal complete definition
Instances
| BaseCaseSearching a 0 => BaseCase a # | Overlappable |
Defined in Generic.Random.Internal.BaseCase | |
type family IfM (b :: Maybe t) (c :: k) (d :: k) :: k #
Instances
| type IfM (Nothing :: Maybe t) (c :: k) (d :: k) # | |
Defined in Generic.Random.Internal.BaseCase | |
| type IfM (Just t2 :: Maybe t1) (c :: k) (d :: k) # | |
Defined in Generic.Random.Internal.BaseCase | |
type family (b :: Maybe Nat) ||? (c :: Maybe Nat) :: Maybe Nat #
type family (b :: Maybe Nat) &&? (c :: Maybe Nat) :: Maybe Nat #
type family MaxOf (e :: Ordering) (m :: k) (n :: k) :: k #
Instances
| type MaxOf LT (m :: k) (n :: k) # | |
Defined in Generic.Random.Internal.BaseCase | |
| type MaxOf EQ (m :: k) (n :: k) # | |
Defined in Generic.Random.Internal.BaseCase | |
| type MaxOf GT (m :: k) (n :: k) # | |
Defined in Generic.Random.Internal.BaseCase | |
type family MinOf (e :: Ordering) (m :: k) (n :: k) :: k #
Instances
| type MinOf LT (m :: k) (n :: k) # | |
Defined in Generic.Random.Internal.BaseCase | |
| type MinOf EQ (m :: k) (n :: k) # | |
Defined in Generic.Random.Internal.BaseCase | |
| type MinOf GT (m :: k) (n :: k) # | |
Defined in Generic.Random.Internal.BaseCase | |
class Alternative (IfM y Weighted Proxy) => GBCS (f :: k -> *) (z :: Nat) (y :: Maybe Nat) (e :: *) where #
Minimal complete definition
Instances
| ((TypeError ((((Text "Unrecognized Rep: " :<>: ShowType f) :$$: Text "Possible causes:") :$$: ((Text " Missing (" :<>: ShowType (BaseCase e)) :<>: Text ") constraint")) :$$: Text " Missing Generic instance") :: Constraint), Alternative (IfM y Weighted (Proxy :: * -> *))) => GBCS (f :: k -> *) z y e # | |
| y ~ Just 0 => GBCS (U1 :: k -> *) z y e # | |
| y ~ (Nothing :: Maybe Nat) => GBCS (K1 i c :: k -> *) 0 y e # | |
| (GBCSSum f g z e yf yg, GBCS f z yf e, GBCS g z yg e, y ~ (yf ||? yg)) => GBCS (f :+: g :: k -> *) z y e # | |
| (GBCSProduct f g z e yf yg, GBCS f z yf e, GBCS g z yg e, y ~ (yf &&? yg)) => GBCS (f :*: g :: k -> *) z y e # | |
| (BaseCaseSearch c (z - 1) y e, (z == 0) ~ False, Alternative (IfM y Weighted (Proxy :: * -> *)), IsMaybe y) => GBCS (K1 i c :: k -> *) z y e # | |
| GBCS f z y e => GBCS (M1 i c f :: k -> *) z y e # | |
class Alternative (IfM (yf ||? yg) Weighted Proxy) => GBCSSum f g z e yf yg where #
Minimal complete definition
Methods
gbcsSum :: 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) #
Instances
| GBCSSum (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) (Nothing :: Maybe Nat) (Nothing :: Maybe Nat) # | |
| GBCSSum (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) (Nothing :: Maybe Nat) (Just n) # | |
| GBCSSum (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) (Just m) (Nothing :: Maybe Nat) # | |
| GBCSSumCompare f g z e (CmpNat m n) => GBCSSum (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) (Just m) (Just n) # | |
class GBCSSumCompare f g z e o where #
Minimal complete definition
Methods
gbcsSumCompare :: proxy0 o -> proxy '(z, e) -> Weighted (f p) -> Weighted (g p) -> Weighted ((f :+: g) p) #
Instances
| GBCSSumCompare (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) GT # | |
Defined in Generic.Random.Internal.BaseCase | |
| GBCSSumCompare (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) LT # | |
Defined in Generic.Random.Internal.BaseCase | |
| GBCSSumCompare (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) EQ # | |
Defined in Generic.Random.Internal.BaseCase | |
class Alternative (IfM (yf &&? yg) Weighted Proxy) => GBCSProduct f g z e yf yg where #
Minimal complete definition
Methods
gbcsProduct :: 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 GBaseCaseSearch a z y e where #
Minimal complete definition
Methods
gBaseCaseSearch :: prox y -> proxy '(z, e) -> IfM y Gen Proxy a #