generic-random- Generic random generators

Safe HaskellNone





data SomeData m where Source


SomeData :: Data a => m a -> SomeData m 


Show (SomeData m) Source

Dummy instance for debugging.

data Alias m where Source


Alias :: (Data a, Data b) => !(m a -> m b) -> Alias m 


Show (Alias m) Source

Dummy instance for debugging.

type AliasR m = Alias (RejectT m) Source

alias :: (Monad m, Data a, Data b) => (a -> m b) -> Alias m Source

Main constructor for Alias.

aliasR :: (Monad m, Data a, Data b) => (a -> m b) -> AliasR m Source

Main constructor for AliasR.

coerceAlias :: Coercible m n => Alias m -> Alias n Source

coerceAlias :: Alias m -> Alias (AMonadRandom m)

coerceAliases :: Coercible m n => [Alias m] -> [Alias n] Source

coerceAliases :: [Alias m] -> [Alias (AMonadRandom m)]

composeCastM :: forall a b c d m. (?loc :: CallStack, Typeable b, Typeable c) => (m c -> d) -> (a -> m b) -> a -> d Source

composeCast f g = f . g

castM :: forall a b m. (?loc :: CallStack, Typeable a, Typeable b) => m a -> m b Source

unSomeData :: (?loc :: CallStack, Typeable a) => SomeData m -> m a Source

applyCast :: (Typeable a, Data b) => (m a -> m b) -> SomeData m -> SomeData m Source

castError :: (?loc :: CallStack, Typeable a, Typeable b) => proxy a -> proxy' b -> c Source

withProxy :: (?loc :: CallStack) => (a -> b) -> proxy a -> b Source

reproxy :: proxy a -> Proxy a Source

proxyType :: m a -> proxy a -> m a Source

someData' :: Data a => proxy a -> SomeData' Source

type Size = Int Source

Size as the number of constructors.

newtype RejectT m a Source

Internal transformer for rejection sampling.

ReaderT Size (StateT Size (MaybeT m)) a




unRejectT :: forall r. Size -> Size -> m r -> (Size -> a -> m r) -> m r

runRejectT :: Monad m => (Size, Size) -> RejectT m a -> m a Source

Set lower bound


class Monad m => MonadRandomLike m where Source

MonadRandomLike m defines basic components to build generators, allowing the implementation to remain abstract over both the Gen type and MonadRandom instances.

For the latter, the wrapper AMonadRandom is provided to avoid overlapping instances.

Minimal complete definition

doubleR, integerR, int, double, char


incr :: m () Source

Called for every constructor. Counter for ceiled rejection sampling.

doubleR :: Double -> m Double Source

doubleR upperBound: generates values in [0, upperBound].

integerR :: Integer -> m Integer Source

integerR upperBound: generates values in [0, upperBound-1].

int :: m Int Source

Default Int generator.

double :: m Double Source

Default Double generator.

char :: m Char Source

Default Char generator.