chatty-utils-0.7.3.4: Some utilities every serious chatty-based application may need.

Safe HaskellSafe
LanguageHaskell2010

Data.Chatty.Counter

Description

Provides a counter monad.

Synopsis

Documentation

newtype CounterT m a Source #

A counter monad.

Constructors

Counter 

Fields

Instances

MonadTrans CounterT Source # 

Methods

lift :: Monad m => m a -> CounterT m a #

Monad m => Monad (CounterT m) Source # 

Methods

(>>=) :: CounterT m a -> (a -> CounterT m b) -> CounterT m b #

(>>) :: CounterT m a -> CounterT m b -> CounterT m b #

return :: a -> CounterT m a #

fail :: String -> CounterT m a #

Functor m => Functor (CounterT m) Source # 

Methods

fmap :: (a -> b) -> CounterT m a -> CounterT m b #

(<$) :: a -> CounterT m b -> CounterT m a #

(Functor m, Monad m) => Applicative (CounterT m) Source # 

Methods

pure :: a -> CounterT m a #

(<*>) :: CounterT m (a -> b) -> CounterT m a -> CounterT m b #

(*>) :: CounterT m a -> CounterT m b -> CounterT m b #

(<*) :: CounterT m a -> CounterT m b -> CounterT m a #

Monad m => ChCounter (CounterT m) Source # 

class Monad m => ChCounter m where Source #

Typeclass for all counter monads.

Minimal complete definition

countOn

Methods

countOn :: m Int Source #

Tell the current number and increment it

withCounter :: (Monad m, Functor m) => CounterT m a -> m a Source #

Run the given function inside a counter