generic-random-1.2.0.0: Generic random generators

Safe HaskellNone
LanguageHaskell2010

Generic.Random.Internal.BaseCase

Synopsis

Documentation

genericArbitrary' #

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

baseCaseSearch

Methods

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

Instances
y ~ Just 0 => BaseCaseSearch Bool z y e # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

y ~ Just 0 => BaseCaseSearch Char z y e # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

y ~ Just 0 => BaseCaseSearch Double z y e # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

y ~ Just 0 => BaseCaseSearch Float z y e # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

y ~ Just 0 => BaseCaseSearch Int z y e # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

y ~ Just 0 => BaseCaseSearch Integer z y e # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

y ~ Just 0 => BaseCaseSearch Ordering z y e # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

y ~ Just 0 => BaseCaseSearch Word z y e # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

y ~ Just 0 => BaseCaseSearch () z y e # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

GBaseCaseSearch a z y e => BaseCaseSearch a z y e # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

y ~ Just 0 => BaseCaseSearch [a] z y e # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

class BaseCaseSearching_ a z y where #

Minimal complete definition

baseCaseSearching_

Methods

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

Instances
BaseCaseSearching a (z + 1) => BaseCaseSearching_ a (z :: Nat) (Nothing :: Maybe t) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

BaseCaseSearching_ a (z :: k) (Just m :: Maybe t) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

class BaseCaseSearching a z where #

Progressively increase the depth bound for BaseCaseSearch.

Minimal complete definition

baseCaseSearching

Methods

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

Instances
(BaseCaseSearch a z y a, BaseCaseSearching_ a z y) => BaseCaseSearching a (z :: Nat) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

class BaseCase a where #

Custom instances can override the default behavior.

Minimal complete definition

baseCase

Methods

baseCase :: Gen a #

Generator of base cases.

Instances
BaseCaseSearching a 0 => BaseCase a #

Overlappable

Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

baseCase :: Gen a #

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

Instances
type IfM (Nothing :: Maybe t) (c :: k) (d :: k) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

type IfM (Nothing :: Maybe t) (c :: k) (d :: k) = d
type IfM (Just t2 :: Maybe t1) (c :: k) (d :: k) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

type IfM (Just t2 :: Maybe t1) (c :: k) (d :: k) = c

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

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

Instances
type IsEQ LT # 
Instance details

Defined in Generic.Random.Internal.BaseCase

type IsEQ LT = False
type IsEQ EQ # 
Instance details

Defined in Generic.Random.Internal.BaseCase

type IsEQ EQ = True
type IsEQ GT # 
Instance details

Defined in Generic.Random.Internal.BaseCase

type IsEQ GT = False

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

Instances
type m ||? (Nothing :: Maybe Nat) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

type m ||? (Nothing :: Maybe Nat) = m
type (Nothing :: Maybe Nat) ||? n # 
Instance details

Defined in Generic.Random.Internal.BaseCase

type (Nothing :: Maybe Nat) ||? n = n
type (Just m) ||? (Just n) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

type (Just m) ||? (Just n) = Just (Min m n)

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

Instances
type m &&? (Nothing :: Maybe Nat) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

type m &&? (Nothing :: Maybe Nat) = (Nothing :: Maybe Nat)
type (Nothing :: Maybe Nat) &&? n # 
Instance details

Defined in Generic.Random.Internal.BaseCase

type (Nothing :: Maybe Nat) &&? n = (Nothing :: Maybe Nat)
type (Just m) &&? (Just n) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

type (Just m) &&? (Just n) = Just (Max m n)

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

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

Instances
type MaxOf LT (m :: k) (n :: k) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

type MaxOf LT (m :: k) (n :: k) = n
type MaxOf EQ (m :: k) (n :: k) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

type MaxOf EQ (m :: k) (n :: k) = m
type MaxOf GT (m :: k) (n :: k) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

type MaxOf GT (m :: k) (n :: k) = m

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

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

Instances
type MinOf LT (m :: k) (n :: k) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

type MinOf LT (m :: k) (n :: k) = m
type MinOf EQ (m :: k) (n :: k) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

type MinOf EQ (m :: k) (n :: k) = n
type MinOf GT (m :: k) (n :: k) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

type MinOf GT (m :: k) (n :: k) = n

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

Minimal complete definition

gbcs

Methods

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

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 # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

y ~ Just 0 => GBCS (U1 :: k -> *) z y e # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

y ~ (Nothing :: Maybe Nat) => GBCS (K1 i c :: k -> *) 0 y e # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

gbcs :: prox y -> proxy (0, e) -> IfM y Weighted Proxy (K1 i c p) #

(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 # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

(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 # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

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

Defined in Generic.Random.Internal.BaseCase

Methods

gbcs :: prox y -> proxy (z, e) -> IfM y Weighted Proxy (K1 i c p) #

GBCS f z y e => GBCS (M1 i c f :: k -> *) z y e # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

gbcs :: prox y -> proxy (z, e) -> IfM y Weighted Proxy (M1 i c f p) #

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

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

Instances
GBCSSum (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) (Nothing :: Maybe Nat) (Nothing :: Maybe Nat) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

gbcsSum :: prox (Nothing, Nothing) -> proxy (z, e) -> IfM Nothing Weighted Proxy (f p) -> IfM Nothing Weighted Proxy (g p) -> IfM (Nothing ||? Nothing) Weighted Proxy ((f :+: g) p) #

GBCSSum (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) (Nothing :: Maybe Nat) (Just n) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

GBCSSum (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) (Just m) (Nothing :: Maybe Nat) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

GBCSSumCompare f g z e (CmpNat m n) => GBCSSum (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) (Just m) (Just n) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

class GBCSSumCompare f g z e o where #

Minimal complete definition

gbcsSumCompare

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 # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

GBCSSumCompare (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) LT # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

GBCSSumCompare (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) EQ # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

gbcsSumCompare :: proxy0 EQ -> 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 where #

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

Instances
(yf &&? yg) ~ (Nothing :: Maybe Nat) => GBCSProduct (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) yf yg # 
Instance details

Defined in Generic.Random.Internal.BaseCase

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

GBCSProduct (f :: k3 -> *) (g :: k3 -> *) (z :: k2) (e :: k1) (Just m) (Just n) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

class IsMaybe b where #

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

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

Instances
IsMaybe (Nothing :: Maybe t) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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

ifM :: proxy Nothing -> c a -> d a -> IfM Nothing c d a #

IsMaybe (Just t2 :: Maybe t1) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

ifMmap :: proxy (Just t2) -> (c a -> c' a') -> (d a -> d' a') -> IfM (Just t2) c d a -> IfM (Just t2) c' d' a' #

ifM :: proxy (Just t2) -> c a -> d a -> IfM (Just t2) c d a #

class GBaseCaseSearch a z y e where #

Minimal complete definition

gBaseCaseSearch

Methods

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

Instances
(Generic a, GBCS (Rep a) z y e, IsMaybe y) => GBaseCaseSearch a (z :: Nat) (y :: Maybe Nat) (e :: *) # 
Instance details

Defined in Generic.Random.Internal.BaseCase

Methods

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