Control.Monad.Free.Improve

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

Safe Haskell | Safe
Language | Haskell98

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 #

Constructors

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

Instances

MonadTrans C # |
Methods lift :: Monad m => m a -> C m a #
(Monad m, Functor f) => MonadFree f (C (FreeT f m)) # |
Methods free :: C (FreeT f m) a -> C (FreeT f m) (Either a (f (C (FreeT f m) a))) # wrap :: f (C (FreeT f m) a) -> C (FreeT f m) a #
Functor f => MonadFree f (C (Free f)) # |
Methods free :: C (Free f) a -> C (Free f) (Either a (f (C (Free f) a))) # wrap :: f (C (Free f) a) -> C (Free f) a #
Monad (C mu) # |
Methods (>>=) :: C mu a -> (a -> C mu b) -> C mu b # (>>) :: C mu a -> C mu b -> C mu b # return :: a -> C mu a # fail :: String -> C mu a #
Functor (C mu) # |
Methods fmap :: (a -> b) -> C mu a -> C mu b # (<$) :: a -> C mu b -> C mu a #
Applicative (C mu) # |
Methods pure :: a -> C mu a # (<*>) :: C mu (a -> b) -> C mu a -> C mu b # (*>) :: C mu a -> C mu b -> C mu b # (<*) :: C mu a -> C mu b -> C mu a #
MonadPlus mu => Alternative (C mu) # |
Methods empty :: C mu a # (<|>) :: C mu a -> C mu a -> C mu a # some :: C mu a -> C mu [a] # many :: C mu a -> C mu [a] #
MonadPlus mu => MonadPlus (C mu) # |
Methods mzero :: C mu a # mplus :: C mu a -> C mu a -> C mu a #

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

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