control-monad-free-0.5.0.1: Free monads and monad transformers

Control.Monad.Free.Improve

Description

Naive Free monads suffer from a quadratic complexity, as explained in

  • Janis Voigtlander, Asymptotic Improvement of Computations over Free Monads, MPC'08

The solution is to redefine the Free datatype in CPS, similar to what is done in difference lists to solve the problem on quadratic append for lists.

Documentation

newtype C mu a Source

Constructors

C (forall b. (a -> mu b) -> mu b) 

Instances

Functor f => MonadFree f (C (Free f)) 
Monad (C mu) 
Functor (C mu) 
MonadPlus mu => MonadPlus (C mu) 

rep :: Monad mu => mu a -> C mu aSource

improve :: Monad mu => C mu a -> mu aSource