Safe Haskell | None |
---|---|
Language | Haskell2010 |
Random variables in uniform and exponential distributions, with interleaving.
Since: 1.0
Synopsis
- data Random m k where
- uniform :: (Random a, Has Random sig m) => m a
- uniformR :: (Random a, Has Random sig m) => (a, a) -> m a
- interleave :: Has Random sig m => m a -> m a
- exponential :: (Random a, Floating a, Has Random sig m) => a -> m a
- class Monad m => Algebra (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) | m -> sig
- type Has (eff :: (Type -> Type) -> Type -> Type) (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) = (Members eff sig, Algebra sig m)
- run :: Identity a -> a
Random effect
data Random m k where Source #
Uniformly-distributed random variables, with interleaving.
Since: 1.0
uniform :: (Random a, Has Random sig m) => m a Source #
Produce a random variable uniformly distributed in a range determined by its type’s Random
instance. For example:
- bounded types (instances of
Bounded
, such asChar
) typically sample all of the constructors. - fractional types, the range is normally the semi-closed interval [0,1).
- for
Integer
, the range is (arbitrarily) the range ofInt
.
Since: 1.1
interleave :: Has Random sig m => m a -> m a Source #
Run a computation by splitting the generator, using one half for the passed computation and the other for the continuation.
interleave
(pure
a) =pure
a
Since: 1.0
Non-uniform distributions
exponential :: (Random a, Floating a, Has Random sig m) => a -> m a Source #
Produce a random variable in an expnoential distribution with the given scale.
Since: 1.1
Re-exports
class Monad m => Algebra (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) | m -> sig #
The class of carriers (results) for algebras (effect handlers) over signatures (effects), whose actions are given by the alg
method.
Since: fused-effects-1.0.0.0
Instances
Algebra NonDet [] | |
Algebra Empty Maybe | |
Algebra Choose NonEmpty | |
Algebra sig m => Algebra sig (IdentityT m) | |
Algebra sig m => Algebra sig (Ap m) | This instance permits effectful actions to be lifted into the mappend <$> act1 <*> (mappend <$> act2 <*> act3) is equivalent to getAp (act1 <> act2 <> act3) Since: fused-effects-1.0.1.0 |
Algebra sig m => Algebra sig (Alt m) | This instance permits effectful actions to be lifted into the a <|> b <|> c <|> d is equivalent to getAlt (mconcat [a, b, c, d]) Since: fused-effects-1.0.1.0 |
Algebra (Lift IO) IO | |
Algebra (Lift Identity) Identity | |
Monoid w => Algebra (Writer w) ((,) w) | |
Algebra (Error e) (Either e) | |
Algebra (Reader r) ((->) r :: Type -> Type) | |
Algebra sig m => Algebra (Empty :+: sig) (MaybeT m) | |
(Algebra sig m, Monoid w) => Algebra (Writer w :+: sig) (WriterT w m) | |
(Algebra sig m, Monoid w) => Algebra (Writer w :+: sig) (WriterT w m) | |
(Algebra sig m, Monoid w) => Algebra (Writer w :+: sig) (WriterT w m) | |
Algebra sig m => Algebra (Error e :+: sig) (ExceptT e m) | |
Algebra sig m => Algebra (State s :+: sig) (StateT s m) | |
Algebra sig m => Algebra (State s :+: sig) (StateT s m) | |
Algebra sig m => Algebra (State s :+: sig) (StateC s m) | |
Algebra sig m => Algebra (Reader r :+: sig) (ReaderT r m) | |
(Algebra sig m, RandomGen g) => Algebra (Random :+: sig) (RandomC g m) Source # | |
(Algebra sig m, Monoid w) => Algebra (Reader r :+: (Writer w :+: (State s :+: sig))) (RWST r w s m) | |
(Algebra sig m, Monoid w) => Algebra (Reader r :+: (Writer w :+: (State s :+: sig))) (RWST r w s m) | |
(Algebra sig m, Monoid w) => Algebra (Reader r :+: (Writer w :+: (State s :+: sig))) (RWST r w s m) | |
type Has (eff :: (Type -> Type) -> Type -> Type) (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) = (Members eff sig, Algebra sig m) #
m
is a carrier for sig
containing eff
.
Note that if eff
is a sum, it will be decomposed into multiple Member
constraints. While this technically allows one to combine multiple unrelated effects into a single Has
constraint, doing so has two significant drawbacks:
- Due to a problem with recursive type families, this can lead to significantly slower compiles.
- It defeats
ghc
’s warnings for redundant constraints, and thus can lead to a proliferation of redundant constraints as code is changed.
Since: fused-effects-1.0.0.0