weighted-0.3.0.1: Writer monad which uses semiring constraint

Synopsis

# Documentation

class (Semiring w, Monad m) => MonadWeighted w m | m -> w where Source #

A class for computations which carry a weight with them. It is analogous to Writer over the Product Monoid.

Methods

weighted :: (a, w) -> m a Source #

weighted (a,w) embeds a simple weighted action.

weight :: w -> m () Source #

weight w is an action that produces the output w.

weigh :: m a -> m (a, w) Source #

weigh m is an action that executes the action m and adds its output to the value of the computation.

scale :: m (a, w -> w) -> m a Source #

scale m is an action that executes the action m, which returns a value and a function, and returns the value, applying the function to the output.

Instances