# Contstuff

### From HaskellWiki

(Difference between revisions)

(Initial revision.) |
m (→Introduction: Fixed wiki markup typo.) |
||

Line 1: | Line 1: | ||

== Introduction == | == Introduction == | ||

− | The [http://hackage.haskell.org/package/contstuff contstuff library] implements a number of monad transformers and monads, which make heavy use of [continuation passing style] (CPS). This makes them both fast and flexible. Please note that this is neither a CPS tutorial nor a monad transformer tutorial. You should understand these concepts, before attempting to use ''contstuff''. | + | The [http://hackage.haskell.org/package/contstuff contstuff library] implements a number of monad transformers and monads, which make heavy use of [[continuation passing style]] (CPS). This makes them both fast and flexible. Please note that this is neither a CPS tutorial nor a monad transformer tutorial. You should understand these concepts, before attempting to use ''contstuff''. |

== ContT == | == ContT == |

## Revision as of 22:44, 20 September 2010

## 1 Introduction

The contstuff library implements a number of monad transformers and monads, which make heavy use of continuation passing style (CPS). This makes them both fast and flexible. Please note that this is neither a CPS tutorial nor a monad transformer tutorial. You should understand these concepts, before attempting to use *contstuff*.

## 2 ContT

TheContT

- abortion (premature termination),
- resumption (start a computation at a certain spot),
- branches (aka
*goto*), - result accumulation,
- etc.

ContT

ContT

ContT r m a

a

r

r

abort

testComp1 :: ContT () IO () testComp1 = forever $ do txt <- io getLine case txt of "info" -> io $ putStrLn "This is a test computation." "quit" -> abort () _ -> return ()

ContT

ContT

io

liftIO

inBase

IO

base

ContT

ContT

abort

ContT

runContT

evalContT

runContT :: (a -> m r) -> ContT r m a -> m r evalContT :: Applicative m => ContT r m r -> m r

runContT

evalContT

pure