generic-random-1.1.0.0: Generic random generators

Safe HaskellNone
LanguageHaskell2010

Generic.Random.Internal.BaseCase

Synopsis

Documentation

genericArbitrary' Source #

Arguments

:: (GArbitrary SizedOpts 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

genericArbitraryU' :: (GArbitrary SizedOpts a, BaseCase a, GUniformWeight a) => Gen a Source #

Equivalent to genericArbitrary' uniform.

genericArbitraryU :: Gen a

withBaseCase :: Gen a -> Gen a -> Gen a Source #

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 Source #

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

baseCaseSearch

Methods

baseCaseSearch :: prox y -> proxy '(z, e) -> IfM y Gen Proxy a Source #

Instances

(~) (Maybe Nat) y (Just Nat 0) => BaseCaseSearch Bool z y e Source # 

Methods

baseCaseSearch :: prox y -> proxy ((Nat, *) z e) -> IfM Nat (* -> *) y Gen (Proxy *) Bool Source #

(~) (Maybe Nat) y (Just Nat 0) => BaseCaseSearch Char z y e Source # 

Methods

baseCaseSearch :: prox y -> proxy ((Nat, *) z e) -> IfM Nat (* -> *) y Gen (Proxy *) Char Source #

(~) (Maybe Nat) y (Just Nat 0) => BaseCaseSearch Double z y e Source # 

Methods

baseCaseSearch :: prox y -> proxy ((Nat, *) z e) -> IfM Nat (* -> *) y Gen (Proxy *) Double Source #

(~) (Maybe Nat) y (Just Nat 0) => BaseCaseSearch Float z y e Source # 

Methods

baseCaseSearch :: prox y -> proxy ((Nat, *) z e) -> IfM Nat (* -> *) y Gen (Proxy *) Float Source #

(~) (Maybe Nat) y (Just Nat 0) => BaseCaseSearch Int z y e Source # 

Methods

baseCaseSearch :: prox y -> proxy ((Nat, *) z e) -> IfM Nat (* -> *) y Gen (Proxy *) Int Source #

(~) (Maybe Nat) y (Just Nat 0) => BaseCaseSearch Integer z y e Source # 

Methods

baseCaseSearch :: prox y -> proxy ((Nat, *) z e) -> IfM Nat (* -> *) y Gen (Proxy *) Integer Source #

(~) (Maybe Nat) y (Just Nat 0) => BaseCaseSearch Ordering z y e Source # 

Methods

baseCaseSearch :: prox y -> proxy ((Nat, *) z e) -> IfM Nat (* -> *) y Gen (Proxy *) Ordering Source #

(~) (Maybe Nat) y (Just Nat 0) => BaseCaseSearch Word z y e Source # 

Methods

baseCaseSearch :: prox y -> proxy ((Nat, *) z e) -> IfM Nat (* -> *) y Gen (Proxy *) Word Source #

(~) (Maybe Nat) y (Just Nat 0) => BaseCaseSearch () z y e Source # 

Methods

baseCaseSearch :: prox y -> proxy ((Nat, *) z e) -> IfM Nat (* -> *) y Gen (Proxy *) () Source #

GBaseCaseSearch Nat Nat * a z y e => BaseCaseSearch a z y e Source # 

Methods

baseCaseSearch :: prox y -> proxy ((Nat, *) z e) -> IfM Nat (* -> *) y Gen (Proxy *) a Source #

(~) (Maybe Nat) y (Just Nat 0) => BaseCaseSearch [a] z y e Source # 

Methods

baseCaseSearch :: prox y -> proxy ((Nat, *) z e) -> IfM Nat (* -> *) y Gen (Proxy *) [a] Source #

class BaseCaseSearching_ a z y where Source #

Minimal complete definition

baseCaseSearching_

Methods

baseCaseSearching_ :: proxy y -> proxy2 '(z, a) -> IfM y Gen Proxy a -> Gen a Source #

Instances

BaseCaseSearching Nat a ((+) z 1) => BaseCaseSearching_ Nat t a z (Nothing t) Source # 

Methods

baseCaseSearching_ :: proxy y -> proxy2 ((a, *) z (Nothing t)) -> IfM z (* -> *) y Gen (Proxy *) (Nothing t) -> Gen (Nothing t) Source #

BaseCaseSearching_ k t a z (Just t m) Source # 

Methods

baseCaseSearching_ :: proxy y -> proxy2 ((a, *) z (Just t m)) -> IfM z (* -> *) y Gen (Proxy *) (Just t m) -> Gen (Just t m) Source #

class BaseCaseSearching a z where Source #

Progressively increase the depth bound for BaseCaseSearch.

Minimal complete definition

baseCaseSearching

Methods

baseCaseSearching :: proxy '(z, a) -> Gen a Source #

Instances

(BaseCaseSearch a z y a, BaseCaseSearching_ Nat Nat a z y) => BaseCaseSearching Nat a z Source # 

Methods

baseCaseSearching :: proxy ((a, *) z z) -> Gen z Source #

class BaseCase a where Source #

Custom instances can override the default behavior.

Minimal complete definition

baseCase

Methods

baseCase :: Gen a Source #

Generator of base cases.

Instances

BaseCaseSearching Nat a 0 => BaseCase a Source #

Overlappable

Methods

baseCase :: Gen a Source #

type family IfM (b :: Maybe t) (c :: k) (d :: k) :: k Source #

Instances

type IfM t k (Nothing t) c d Source # 
type IfM t k (Nothing t) c d = d
type IfM t1 k (Just t1 t2) c d Source # 
type IfM t1 k (Just t1 t2) c d = c

type (==) m n = IsEQ (CmpNat m n) Source #

type family IsEQ (e :: Ordering) :: Bool Source #

Instances

type IsEQ LT Source # 
type IsEQ LT = False
type IsEQ EQ Source # 
type IsEQ EQ = True
type IsEQ GT Source # 
type IsEQ GT = False

type family (b :: Maybe Nat) ||? (c :: Maybe Nat) :: Maybe Nat Source #

Instances

type m ||? (Nothing Nat) Source # 
type m ||? (Nothing Nat) = m
type (Nothing Nat) ||? n Source # 
type (Nothing Nat) ||? n = n
type (Just Nat m) ||? (Just Nat n) Source # 
type (Just Nat m) ||? (Just Nat n) = Just Nat (Min m n)

type family (b :: Maybe Nat) &&? (c :: Maybe Nat) :: Maybe Nat Source #

Instances

type m &&? (Nothing Nat) Source # 
type (Nothing Nat) &&? n Source # 
type (Just Nat m) &&? (Just Nat n) Source # 
type (Just Nat m) &&? (Just Nat n) = Just Nat (Max m n)

type Max m n = MaxOf (CmpNat m n) m n Source #

type family MaxOf (e :: Ordering) (m :: k) (n :: k) :: k Source #

Instances

type MaxOf k LT m n Source # 
type MaxOf k LT m n = n
type MaxOf k EQ m n Source # 
type MaxOf k EQ m n = m
type MaxOf k GT m n Source # 
type MaxOf k GT m n = m

type Min m n = MinOf (CmpNat m n) m n Source #

type family MinOf (e :: Ordering) (m :: k) (n :: k) :: k Source #

Instances

type MinOf k LT m n Source # 
type MinOf k LT m n = m
type MinOf k EQ m n Source # 
type MinOf k EQ m n = n
type MinOf k GT m n Source # 
type MinOf k GT m n = n

class Alternative (IfM y Weighted Proxy) => GBCS (f :: k -> *) (z :: Nat) (y :: Maybe Nat) (e :: *) where Source #

Minimal complete definition

gbcs

Methods

gbcs :: prox y -> proxy '(z, e) -> IfM y Weighted Proxy (f p) Source #

Instances

(TypeError Constraint ((:$$:) ((:$$:) ((:$$:) ((:<>:) (Text "Unrecognized Rep: ") (ShowType (k -> *) f)) (Text "Possible causes:")) ((:<>:) ((:<>:) (Text " Missing (") (ShowType Constraint (BaseCase e))) (Text ") constraint"))) (Text " Missing Generic instance")), Alternative (IfM Nat (* -> *) y Weighted (Proxy *))) => GBCS k f z y e Source # 

Methods

gbcs :: prox e -> proxy ((Nat, *) y e) -> IfM Nat (* -> *) e Weighted (Proxy *) (z p) Source #

(~) (Maybe Nat) y (Just Nat 0) => GBCS k (U1 k) z y e Source # 

Methods

gbcs :: prox e -> proxy ((Nat, *) y e) -> IfM Nat (* -> *) e Weighted (Proxy *) (z p) Source #

(~) (Maybe Nat) y (Nothing Nat) => GBCS k (K1 k i c) 0 y e Source # 

Methods

gbcs :: prox e -> proxy ((Nat, *) y e) -> IfM Nat (* -> *) e Weighted (Proxy *) (0 p) Source #

(GBCSSum k Nat * f g z e yf yg, GBCS k f z yf e, GBCS k g z yg e, (~) (Maybe Nat) y ((||?) yf yg)) => GBCS k ((:+:) k f g) z y e Source # 

Methods

gbcs :: prox e -> proxy ((Nat, *) y e) -> IfM Nat (* -> *) e Weighted (Proxy *) (z p) Source #

(GBCSProduct k Nat * f g z e yf yg, GBCS k f z yf e, GBCS k g z yg e, (~) (Maybe Nat) y ((&&?) yf yg)) => GBCS k ((:*:) k f g) z y e Source # 

Methods

gbcs :: prox e -> proxy ((Nat, *) y e) -> IfM Nat (* -> *) e Weighted (Proxy *) (z p) Source #

(BaseCaseSearch c ((-) z 1) y e, (~) Bool ((==) z 0) False, Alternative (IfM Nat (* -> *) y Weighted (Proxy *)), IsMaybe Nat y) => GBCS k (K1 k i c) z y e Source # 

Methods

gbcs :: prox e -> proxy ((Nat, *) y e) -> IfM Nat (* -> *) e Weighted (Proxy *) (z p) Source #

GBCS k f z y e => GBCS k (M1 k i c f) z y e Source # 

Methods

gbcs :: prox e -> proxy ((Nat, *) y e) -> IfM Nat (* -> *) e Weighted (Proxy *) (z p) Source #

class Alternative (IfM (yf ||? yg) Weighted Proxy) => GBCSSum f g z e yf yg where Source #

Minimal complete definition

gbcsSum

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) Source #

Instances

GBCSSum k3 k2 k1 f g z e (Nothing Nat) (Nothing Nat) Source # 

Methods

gbcsSum :: prox ((Maybe Nat, Maybe Nat) yf yg) -> proxy ((g, z) (Nothing Nat) e) -> IfM Nat (* -> *) yf Weighted (Proxy *) (e p) -> IfM Nat (* -> *) yg Weighted (Proxy *) (Nothing Nat p) -> IfM Nat (* -> *) (yf ||? yg) Weighted (Proxy *) ((f :+: e) (Nothing Nat) p) Source #

GBCSSum k3 k2 k1 f g z e (Nothing Nat) (Just Nat n) Source # 

Methods

gbcsSum :: prox ((Maybe Nat, Maybe Nat) yf yg) -> proxy ((g, z) (Just Nat n) e) -> IfM Nat (* -> *) yf Weighted (Proxy *) (e p) -> IfM Nat (* -> *) yg Weighted (Proxy *) (Nothing Nat p) -> IfM Nat (* -> *) (yf ||? yg) Weighted (Proxy *) ((f :+: e) (Nothing Nat) p) Source #

GBCSSum k3 k2 k1 f g z e (Just Nat m) (Nothing Nat) Source # 

Methods

gbcsSum :: prox ((Maybe Nat, Maybe Nat) yf yg) -> proxy ((g, z) (Nothing Nat) e) -> IfM Nat (* -> *) yf Weighted (Proxy *) (e p) -> IfM Nat (* -> *) yg Weighted (Proxy *) (Just Nat m p) -> IfM Nat (* -> *) (yf ||? yg) Weighted (Proxy *) ((f :+: e) (Just Nat m) p) Source #

GBCSSumCompare k3 k2 k1 Ordering f g z e (CmpNat m n) => GBCSSum k3 k2 k1 f g z e (Just Nat m) (Just Nat n) Source # 

Methods

gbcsSum :: prox ((Maybe Nat, Maybe Nat) yf yg) -> proxy ((g, z) (Just Nat n) e) -> IfM Nat (* -> *) yf Weighted (Proxy *) (e p) -> IfM Nat (* -> *) yg Weighted (Proxy *) (Just Nat m p) -> IfM Nat (* -> *) (yf ||? yg) Weighted (Proxy *) ((f :+: e) (Just Nat m) p) Source #

class GBCSSumCompare f g z e o where Source #

Minimal complete definition

gbcsSumCompare

Methods

gbcsSumCompare :: proxy0 o -> proxy '(z, e) -> Weighted (f p) -> Weighted (g p) -> Weighted ((f :+: g) p) Source #

Instances

GBCSSumCompare k3 k2 k1 Ordering f g z e GT Source # 

Methods

gbcsSumCompare :: proxy0 o -> proxy ((g, z) z e) -> Weighted (GT p) -> Weighted (g p) -> Weighted ((f :+: GT) g p) Source #

GBCSSumCompare k3 k2 k1 Ordering f g z e LT Source # 

Methods

gbcsSumCompare :: proxy0 o -> proxy ((g, z) z e) -> Weighted (LT p) -> Weighted (g p) -> Weighted ((f :+: LT) g p) Source #

GBCSSumCompare k3 k2 k1 Ordering f g z e EQ Source # 

Methods

gbcsSumCompare :: proxy0 o -> proxy ((g, z) z e) -> Weighted (EQ p) -> Weighted (g p) -> Weighted ((f :+: EQ) g p) Source #

class Alternative (IfM (yf &&? yg) Weighted Proxy) => GBCSProduct f g z e yf yg where Source #

Minimal complete definition

gbcsProduct

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) Source #

Instances

(~) (Maybe Nat) ((&&?) yf yg) (Nothing Nat) => GBCSProduct k3 k2 k1 f g z e yf yg Source # 

Methods

gbcsProduct :: prox ((Maybe Nat, Maybe Nat) yf yg) -> proxy ((g, z) yg e) -> IfM Nat (* -> *) yf Weighted (Proxy *) (e p) -> IfM Nat (* -> *) yg Weighted (Proxy *) (yf p) -> IfM Nat (* -> *) (yf &&? yg) Weighted (Proxy *) ((f :*: e) yf p) Source #

GBCSProduct k3 k2 k1 f g z e (Just Nat m) (Just Nat n) Source # 

Methods

gbcsProduct :: prox ((Maybe Nat, Maybe Nat) yf yg) -> proxy ((g, z) (Just Nat n) e) -> IfM Nat (* -> *) yf Weighted (Proxy *) (e p) -> IfM Nat (* -> *) yg Weighted (Proxy *) (Just Nat m p) -> IfM Nat (* -> *) (yf &&? yg) Weighted (Proxy *) ((f :*: e) (Just Nat m) p) Source #

class IsMaybe b where Source #

Minimal complete definition

ifMmap, ifM

Methods

ifMmap :: proxy b -> (c a -> c' a') -> (d a -> d' a') -> IfM b c d a -> IfM b c' d' a' Source #

ifM :: proxy b -> c a -> d a -> IfM b c d a Source #

Instances

IsMaybe t (Nothing t) Source # 

Methods

ifMmap :: proxy b -> (c a -> c' a') -> (d a -> d' a') -> IfM (Nothing t) (k -> *) b c d a -> IfM (Nothing t) (k -> *) b c' d' a' Source #

ifM :: proxy b -> c a -> d a -> IfM (Nothing t) (k -> *) b c d a Source #

IsMaybe t1 (Just t1 t2) Source # 

Methods

ifMmap :: proxy b -> (c a -> c' a') -> (d a -> d' a') -> IfM (Just t1 t2) (k -> *) b c d a -> IfM (Just t1 t2) (k -> *) b c' d' a' Source #

ifM :: proxy b -> c a -> d a -> IfM (Just t1 t2) (k -> *) b c d a Source #

class GBaseCaseSearch a z y e where Source #

Minimal complete definition

gBaseCaseSearch

Methods

gBaseCaseSearch :: prox y -> proxy '(z, e) -> IfM y Gen Proxy a Source #

Instances

(Generic a, GBCS * (Rep a) z y e, IsMaybe Nat y) => GBaseCaseSearch Nat Nat * a z y e Source # 

Methods

gBaseCaseSearch :: prox y -> proxy ((a, y) z e) -> IfM z (* -> *) y Gen (Proxy *) e Source #