fused-effects-1.1.1.1: A fast, flexible, fused effect system.
Safe HaskellNone
LanguageHaskell2010

Control.Carrier.Fresh.Church

Description

A church-encoded carrier for a Fresh effect, providing access to a monotonically increasing stream of Int values.

Since: 1.1.0.0

Synopsis

Fresh carrier

runFresh :: (Int -> a -> m b) -> Int -> FreshC m a -> m b Source #

Run a Fresh effect counting up from 0.

runFresh k n (pure a) = k n a
runFresh k n fresh = k (n + 1) n

Since: 1.1.0.0

evalFresh :: Applicative m => Int -> FreshC m a -> m a Source #

Run a Fresh effect counting up from an initial value, and forgetting the final value.

evalFresh n (pure a) = pure a
evalFresh n fresh = pure n

Since: 1.1.0.0

newtype FreshC m a Source #

Since: 1.1.0.0

Constructors

FreshC (StateC Int m a) 

Instances

Instances details
MonadTrans FreshC Source # 
Instance details

Defined in Control.Carrier.Fresh.Church

Methods

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

Monad (FreshC m) Source # 
Instance details

Defined in Control.Carrier.Fresh.Church

Methods

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

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

return :: a -> FreshC m a #

Functor (FreshC m) Source # 
Instance details

Defined in Control.Carrier.Fresh.Church

Methods

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

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

MonadFix m => MonadFix (FreshC m) Source # 
Instance details

Defined in Control.Carrier.Fresh.Church

Methods

mfix :: (a -> FreshC m a) -> FreshC m a #

MonadFail m => MonadFail (FreshC m) Source # 
Instance details

Defined in Control.Carrier.Fresh.Church

Methods

fail :: String -> FreshC m a #

Applicative (FreshC m) Source # 
Instance details

Defined in Control.Carrier.Fresh.Church

Methods

pure :: a -> FreshC m a #

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

liftA2 :: (a -> b -> c) -> FreshC m a -> FreshC m b -> FreshC m c #

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

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

MonadIO m => MonadIO (FreshC m) Source # 
Instance details

Defined in Control.Carrier.Fresh.Church

Methods

liftIO :: IO a -> FreshC m a #

Alternative m => Alternative (FreshC m) Source # 
Instance details

Defined in Control.Carrier.Fresh.Church

Methods

empty :: FreshC m a #

(<|>) :: FreshC m a -> FreshC m a -> FreshC m a #

some :: FreshC m a -> FreshC m [a] #

many :: FreshC m a -> FreshC m [a] #

(Alternative m, Monad m) => MonadPlus (FreshC m) Source # 
Instance details

Defined in Control.Carrier.Fresh.Church

Methods

mzero :: FreshC m a #

mplus :: FreshC m a -> FreshC m a -> FreshC m a #

Algebra sig m => Algebra (Fresh :+: sig) (FreshC m) Source # 
Instance details

Defined in Control.Carrier.Fresh.Church

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (FreshC m) -> (Fresh :+: sig) n a -> ctx () -> FreshC m (ctx a) Source #

Fresh effect