Portability non-portable (multi-parameter type classes, undecidable instances) Stability experimental
Description

This module provides stripped-down versions of Writer and WriterT, minus the operations tell, listen and pass. It a useful building block for monads representing probability distributions or quantum states, where the extra functions provided by MonadWriter are irrelevant or inappropriate.

The MV monad and the MVT monad transformer were proposed by Dan Piponi as a way of representing M-sets in Haskell. An M-set is a set with a monoid action (by analogy to the more common G-sets found in group theory). Here, MV represents an element in a free M-set. This is essentially a (monoid,value) pair.

Computation type:
Computations with an associated monoid action.
Binding strategy:
The return function lifts a value into the monad by pairing it with mempty. The bind function uses mappend to implement the monoid action.
Useful for:
Synopsis
module Data.Monoid
data MV w a = MV {
 mvMonoid :: w mvValue :: a
}
mvMonoid :: MV w a -> w
mvValue :: MV w a -> a
newtype MVT w m a = MVT {
 runMVT :: (m (MV w a))
}
runMVT :: MVT w m a -> m (MV w a)
Documentation
module Data.Monoid
data MV w a
A value annotated with a monoid. Represents an element in a free M-set.
Constructors
MV
 mvMonoid :: w mvValue :: a
Instances
 Monoid w => Functor (MV w) Monoid w => Monad (MV w) (Monoid w, Show w, Show a) => Show (MV w a)
mvMonoid :: MV w a -> w
mvValue :: MV w a -> a
newtype MVT w m a
Transforms a monad m to associate a monoid value with the computation.
Constructors
MVT
 runMVT :: (m (MV w a))
Instances
 Probability p => BayesDist (MaybeT (MVT p [])) Probability p => MonadPlus (MaybeT (MVT p [])) Monoid w => MonadTrans (MVT w) Probability p => Dist (MVT p []) (Monoid w, Monad m) => Functor (MVT w m) (Monoid w, Monad m) => Monad (MVT w m) (Show a, Ord a, Show p, Probability p) => Show (MVT p [] a)
runMVT :: MVT w m a -> m (MV w a)