monad-supply-0.3: Stateful supply monad.

Safe HaskellNone

Control.Monad.Supply

Description

Support for computations which consume values from a (possibly infinite) supply. See http://www.haskell.org/haskellwiki/New_monads/MonadSupply for details.

Synopsis

Documentation

class Monad m => MonadSupply s m | m -> s whereSource

Instances

MonadSupply s (Supply s) 
(Monoid w, MonadSupply s m) => MonadSupply s (WriterT w m) 
MonadSupply s m => MonadSupply s (ReaderT r m) 
MonadSupply s m => MonadSupply s (StateT st m) 
(Error e, MonadSupply s m) => MonadSupply s (ErrorT e m) 
Monad m => MonadSupply s (SupplyT s m) 

data SupplyT s m a Source

Supply monad transformer.

Instances

Monad m => MonadSupply s (SupplyT s m) 
MonadTrans (SupplyT s) 
Monad m => Monad (SupplyT s m) 
Functor m => Functor (SupplyT s m) 
MonadIO m => MonadIO (SupplyT s m) 

data Supply s a Source

Supply monad.

Instances

MonadSupply s (Supply s) 
Monad (Supply s) 
Functor (Supply s) 
Monoid a => Monoid (Supply s a)

Monoid instance for the supply monad. Actually any monad/monoid pair gives rise to this monoid instance, but we can't write its type like that because it would conflict with existing instances provided by Data.Monoid. instance (Monoid a, Monad m) => Monoid (m a) where

evalSupplyT :: Monad m => SupplyT s m a -> [s] -> m aSource

evalSupply :: Supply s a -> [s] -> aSource

runSupplyT :: Monad m => SupplyT s m a -> [s] -> m (a, [s])Source

runSupply :: Supply s a -> [s] -> (a, [s])Source

supplies :: MonadSupply s m => Int -> m [s]Source

Get n supplies.