Safe Haskell | None |
---|---|
Language | Haskell2010 |
Random variables in uniform and exponential distributions, with interleaving.
Since: 1.0
Synopsis
- data Random (m :: Type -> Type) k where
- uniform :: forall a (sig :: (Type -> Type) -> Type -> Type) m. (Random a, Has Random sig m) => m a
- uniformR :: forall a (sig :: (Type -> Type) -> Type -> Type) m. (Random a, Has Random sig m) => (a, a) -> m a
- interleave :: forall (sig :: (Type -> Type) -> Type -> Type) m a. Has Random sig m => m a -> m a
- exponential :: forall a (sig :: (Type -> Type) -> Type -> Type) m. (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 :: Type -> Type) k where Source #
Uniformly-distributed random variables, with interleaving.
Since: 1.0
uniform :: forall a (sig :: (Type -> Type) -> Type -> Type) m. (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
uniformR :: forall a (sig :: (Type -> Type) -> Type -> Type) m. (Random a, Has Random sig m) => (a, a) -> m a Source #
interleave :: forall (sig :: (Type -> Type) -> Type -> Type) m a. 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 :: forall a (sig :: (Type -> Type) -> Type -> Type) m. (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 Choose NonEmpty | |
Algebra Empty Maybe | |
Algebra NonDet [] | |
Algebra sig m => Algebra sig (Choosing 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 sig m => Algebra sig (IdentityT m) | |
Algebra (Lift Identity) Identity | |
Algebra (Lift IO) IO | |
Algebra (Error e) (Either e) | |
Monad m => Algebra (Lift m) (LiftC m) | |
Monoid w => Algebra (Writer w) ((,) w) | |
Algebra (Reader r) ((->) r) | |
Algebra sig m => Algebra (Choose :+: sig) (ChooseC m) | |
Algebra sig m => Algebra (Cull :+: (NonDet :+: sig)) (CullC m) | |
Algebra sig m => Algebra (Cut :+: (NonDet :+: sig)) (CutC m) | |
Algebra sig m => Algebra (Empty :+: sig) (EmptyC m) | |
Algebra sig m => Algebra (Empty :+: sig) (EmptyC m) | |
Algebra sig m => Algebra (Empty :+: sig) (MaybeT m) | |
Algebra sig m => Algebra (Fail :+: sig) (FailC m) | |
Algebra sig m => Algebra (Fresh :+: sig) (FreshC m) | |
Algebra sig m => Algebra (Fresh :+: sig) (FreshC m) | |
Algebra sig m => Algebra (NonDet :+: sig) (NonDetC m) | |
Algebra sig m => Algebra (Trace :+: sig) (TraceC m) | |
(MonadIO m, Algebra sig m) => Algebra (Trace :+: sig) (TraceC m) | |
Algebra sig m => Algebra (Trace :+: sig) (TraceC m) | |
(Algebra sig m, Monoid w) => Algebra (Accum w :+: sig) (AccumC w m) | |
(Algebra sig m, Semigroup w, MonadIO m) => Algebra (Accum w :+: sig) (AccumC w m) | |
(Algebra sig m, Monoid w) => Algebra (Accum w :+: sig) (AccumC w m) | |
(Algebra sig m, Monoid w) => Algebra (Accum w :+: sig) (AccumT w m) | |
Algebra sig m => Algebra (Error e :+: sig) (ErrorC e m) | |
Algebra sig m => Algebra (Error e :+: sig) (ErrorC e m) | |
Algebra sig m => Algebra (Error e :+: sig) (ExceptT e m) | |
Algebra sig m => Algebra (Reader r :+: sig) (ReaderC r m) | |
Algebra sig m => Algebra (Reader r :+: sig) (ReaderT r m) | |
Algebra sig m => Algebra (State s :+: sig) (StateC s m) | |
(MonadIO m, Algebra sig m) => Algebra (State s :+: sig) (StateC s m) | |
Algebra sig m => Algebra (State s :+: sig) (StateC s m) | |
Algebra sig m => Algebra (State s :+: sig) (StateC s 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 (Throw e :+: sig) (ThrowC e m) | |
(Algebra sig m, Monoid w) => Algebra (Writer w :+: sig) (WriterC w m) | |
(Monoid w, Algebra sig m) => Algebra (Writer w :+: sig) (WriterC 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, Monoid w) => Algebra (Writer w :+: sig) (WriterT w m) | |
(Algebra sig m, RandomGen g) => Algebra (Random :+: sig) (RandomC g m) Source # | |
(Reifies s (Interpreter eff m), Algebra sig m) => Algebra (eff :+: sig) (InterpretC s eff m) | |
Defined in Control.Carrier.Interpret alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (InterpretC s eff m) -> (eff :+: sig) n a -> ctx () -> InterpretC s eff m (ctx a) # | |
Algebra (eff :+: sig) (sub m) => Algebra (Labelled label eff :+: sig) (Labelled label sub 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) | |
(Algebra sig m, Monoid w) => Algebra (Reader r :+: (Writer w :+: (State s :+: sig))) (RWST r w s m) | |
(LabelledMember label sub sig, Algebra sig m) => Algebra (sub :+: sig) (UnderLabel label sub m) | |
Defined in Control.Effect.Labelled alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (UnderLabel label sub m) -> (sub :+: sig) n a -> ctx () -> UnderLabel label sub m (ctx a) # |
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