[Haskell-beginners] More simple continuation questions
martin
martin.drautzburg at web.de
Tue Jul 15 18:32:31 UTC 2014
Hello all,
(1) when reading about continuations, there is this thing which needs an "other function" to be passed to produce a
final result. And there is this "other function". Which of the two is "the continuation"?
http://stackoverflow.com/questions/9050725/call-cc-implementation sais
" ... instead, they are passed a function that represents the 'next step' in the computation - the 'continuation' "
Which sound like the "other function" is called "continuation". But other articles hint in the opposite direction.
(2) When comparing continuations with callbacks, it struck me that the type is
newtype Cont r a = Cont { runCont :: (a -> r) -> r }
So the type of the final result is r. But why does the function (a->r) need to return an r? With regular callbacks this
does not seem to be the case. After returning from the callback the surrounding function is free to do anything it wants
with the return value and return a value of a different type. Why is that so?
More information about the Beginners
mailing list