Safe Haskell | None |
---|---|
Language | Haskell2010 |
Internal module
Derive Boltzmann samplers for SYB-generic types.
- data SG r = SG {}
- type Points = Int
- rangeSG :: SG r -> (Size, Maybe Size)
- applySG :: SG r -> Points -> Maybe Double -> r
- make :: (Data a, MonadRandomLike m) => [Alias m] -> proxy a -> SG (m a)
- makeR :: (Data a, MonadRandomLike m) => [AliasR m] -> proxy a -> SG ((Size, Size) -> m a)
- type Size' = Int
- rescale :: SG r -> Size' -> Double
- apply :: SG r -> Points -> Maybe Size' -> r
- applyR :: SG ((Size, Size) -> r) -> Points -> Maybe Size' -> (Size', Size') -> r
- rescaleInterval :: SG r -> (Size', Size') -> (Size, Size)
- epsilon :: Double
- tolerance :: Double -> Int -> (Int, Int)
- memo :: (t -> [t2] -> SG r) -> (SG r -> t1 -> Maybe Int -> a) -> t -> t1 -> Int -> a
- sparseSized :: (Int -> a) -> Maybe Int -> Int -> a
Documentation
Sized generator.
Helper functions
The size of a value is its number of constructors.
Here, however, the Size'
type is interpreted differently to make better
use of QuickCheck's size parameter provided by the sized
combinator, so that we generate non-trivial data even at very small size
values.
For infinite types, with objects of unbounded sizes > minSize
, given a
parameter delta ::
, the produced values have an average size close
to Size'
minSize + delta
.
For example, values of type Either () [Bool]
have at least two constructors,
so
generator
delta ::Gen
(Either () [Bool])
will target sizes close to 2 + delta
;
the offset becomes less noticeable as delta
grows to infinity.
For finite types with sizes in [minSize, maxSize]
, the target expected
size is obtained by clamping a Size'
to [0, 99]
and applying an affine
mapping.