weighted-0.1.0.1: Writer monad which uses semiring constraint

Safe HaskellNone
LanguageHaskell2010

Control.Monad.Weighted

Synopsis

Documentation

data WeightedT s m a Source #

A monad transformer similar to WriterT, except that it does not leak space, and it uses the Semiring class, rather than Monoid.

Instances

MonadTrans (WeightedT s) Source # 

Methods

lift :: Monad m => m a -> WeightedT s m a #

(Semiring s, Monad m) => MonadWriter (Mul s) (WeightedT s m) Source # 

Methods

writer :: (a, Mul s) -> WeightedT s m a #

tell :: Mul s -> WeightedT s m () #

listen :: WeightedT s m a -> WeightedT s m (a, Mul s) #

pass :: WeightedT s m (a, Mul s -> Mul s) -> WeightedT s m a #

Monad m => Monad (WeightedT s m) Source # 

Methods

(>>=) :: WeightedT s m a -> (a -> WeightedT s m b) -> WeightedT s m b #

(>>) :: WeightedT s m a -> WeightedT s m b -> WeightedT s m b #

return :: a -> WeightedT s m a #

fail :: String -> WeightedT s m a #

Functor m => Functor (WeightedT s m) Source # 

Methods

fmap :: (a -> b) -> WeightedT s m a -> WeightedT s m b #

(<$) :: a -> WeightedT s m b -> WeightedT s m a #

Monad m => Applicative (WeightedT s m) Source # 

Methods

pure :: a -> WeightedT s m a #

(<*>) :: WeightedT s m (a -> b) -> WeightedT s m a -> WeightedT s m b #

(*>) :: WeightedT s m a -> WeightedT s m b -> WeightedT s m b #

(<*) :: WeightedT s m a -> WeightedT s m b -> WeightedT s m a #

(Alternative m, Monad m, Semiring s) => Alternative (WeightedT s m) Source # 

Methods

empty :: WeightedT s m a #

(<|>) :: WeightedT s m a -> WeightedT s m a -> WeightedT s m a #

some :: WeightedT s m a -> WeightedT s m [a] #

many :: WeightedT s m a -> WeightedT s m [a] #

runWeightedT :: Semiring s => WeightedT s m a -> m (a, s) Source #

pattern WeightedT :: forall m s a. (Functor m, Semiring s) => m (a, s) -> WeightedT s m a Source #

runWeighted :: Semiring s => Weighted s a -> (a, s) Source #

pattern Weighted :: forall s a. Semiring s => (a, s) -> Weighted s a Source #

execWeightedT :: (Monad m, Semiring s) => WeightedT s m a -> m s Source #

evalWeightedT :: (Monad m, Semiring s) => WeightedT s m a -> m a Source #