Monad V S Continuation (not finish)

!i have read 1 paper which describe the difference between two method.

在看完http://www.defmacro.org/ramblings/fp.html

這篇文章後，他裡面提到Continuations，剛好我學過Monad，覺得這兩個概念有點相似，都是為了解決Sequence而產生的，只是monad是以接受前一個動作的結果，來執行現在的動作，但是continuation卻是接受未來的動作，然後在做完當前動作後，在執行未來的動作。

Ex: for sequence

```
int t=foo(5);
if(t) then act1 else act2
```

- Continuation passing style: we need to have one more argument which is the function that represents "what to do next".

```
\act1 -> \act2 -> if t then act1 else act2
where t = foo 5
```

- Monad: the argument is the result of the previous computation.

`(foo 5) >>= (\result -> if result then act1 else act2)`

References:

http://en.wikibooks.org/wiki/Haskell/Continuation_passing_style

http://en.wikipedia.org/wiki/Monad_%28functional_programming%29

page revision: 4, last edited: 16 Jan 2008 15:51