HasChor-0.1.0.1: Functional choreographic programming in Haskell
Safe HaskellSafe-Inferred
LanguageGHC2021

Control.Monad.Freer

Description

This module defines the freer monad Freer, which allows manipulating effectful computations algebraically.

Synopsis

Documentation

data Freer f a where Source #

Freer monads.

A freer monad Freer f a represents an effectful computation that returns a value of type a. The parameter f :: * -> * is a effect signature that defines the effectful operations allowed in the computation. Freer f a is called a freer monad in that it's a Monad given any f.

Constructors

Return :: a -> Freer f a

A pure computation.

Do :: f b -> (b -> Freer f a) -> Freer f a

An effectful computation where the first argument f b is the effect to perform and returns a result of type b; the second argument b -> Freer f a is a continuation that specifies the rest of the computation given the result of the performed effect.

Instances

Instances details
Applicative (Freer f) Source # 
Instance details

Defined in Control.Monad.Freer

Methods

pure :: a -> Freer f a #

(<*>) :: Freer f (a -> b) -> Freer f a -> Freer f b #

liftA2 :: (a -> b -> c) -> Freer f a -> Freer f b -> Freer f c #

(*>) :: Freer f a -> Freer f b -> Freer f b #

(<*) :: Freer f a -> Freer f b -> Freer f a #

Functor (Freer f) Source # 
Instance details

Defined in Control.Monad.Freer

Methods

fmap :: (a -> b) -> Freer f a -> Freer f b #

(<$) :: a -> Freer f b -> Freer f a #

Monad (Freer f) Source # 
Instance details

Defined in Control.Monad.Freer

Methods

(>>=) :: Freer f a -> (a -> Freer f b) -> Freer f b #

(>>) :: Freer f a -> Freer f b -> Freer f b #

return :: a -> Freer f a #

toFreer :: f a -> Freer f a Source #

Lift an effect into the freer monad.

interpFreer :: Monad m => (forall a. f a -> m a) -> Freer f a -> m a Source #

Interpret the effects in a freer monad in terms of another monad.