Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Urn a
- type Weight = Word
- class Monad m => MonadSample m
- singleton :: Weight -> a -> Urn a
- fromList :: [(Weight, a)] -> Maybe (Urn a)
- fromNonEmpty :: NonEmpty (Weight, a) -> Urn a
- sample :: MonadSample m => Urn a -> m a
- sampleM :: MonadSample m => Urn (m a) -> m a
- remove :: MonadSample m => Urn a -> m (Weight, a, Maybe (Urn a))
- removeM :: MonadSample m => Urn (m a) -> m (Weight, a, Maybe (Urn (m a)))
- insert :: Weight -> a -> Urn a -> Urn a
- update :: MonadSample m => (Weight -> a -> (Weight, a)) -> Urn a -> m (Weight, a, Weight, a, Urn a)
- replace :: MonadSample m => Weight -> a -> Urn a -> m (Weight, a, Urn a)
- frequency :: MonadSample m => [(Weight, m a)] -> m a
- addToUrn :: Foldable t => Urn a -> t (Weight, a) -> Urn a
- size :: Urn a -> Word
- totalWeight :: Urn a -> Weight
Types
class Monad m => MonadSample m Source #
MonadSample IO Source # | |
MonadSample Gen Source # | |
MonadSample m => MonadSample (MaybeT m) Source # | |
(Monad m, RandomGen g) => MonadSample (RandT g m) Source # | |
MonadSample m => MonadSample (ExceptT e m) Source # | |
MonadSample m => MonadSample (StateT s m) Source # | |
MonadSample m => MonadSample (StateT s m) Source # | |
(MonadSample m, Monoid w) => MonadSample (WriterT w m) Source # | |
(MonadSample m, Monoid w) => MonadSample (WriterT w m) Source # | |
MonadSample m => MonadSample (IdentityT * m) Source # | |
MonadSample m => MonadSample (ContT * r m) Source # | |
MonadSample m => MonadSample (ReaderT * r m) Source # | |
(MonadSample m, Monoid w) => MonadSample (RWST r w s m) Source # | |
(MonadSample m, Monoid w) => MonadSample (RWST r w s m) Source # | |
Construction
Sampling
sample :: MonadSample m => Urn a -> m a Source #
sampleM :: MonadSample m => Urn (m a) -> m a Source #
Updating
update :: MonadSample m => (Weight -> a -> (Weight, a)) -> Urn a -> m (Weight, a, Weight, a, Urn a) Source #
Other functions
frequency :: MonadSample m => [(Weight, m a)] -> m a Source #
Urn
properties
totalWeight :: Urn a -> Weight Source #