First of all, calling Scheme / cc and Haskell callCC are slightly different things, as explained on the page unsupported continuations are not functions
The main problem is that you may not need call / cc at all - even on the Scheme. Your example of exiting the loop is much better implemented using exceptions - better in terms of efficiency (there is no need to fix a continuation that you will not use in any case), and better conceptually. If the task is to interrupt current continuations, there are tools for this purpose. The R7RS recognized this and introduced exceptions. To use exceptions in Haskell, use the error or any monad. For example, in your code
baz :: Either [Int] [Int] baz = foldM (\acc v -> do when (v >= 5) $ Left acc return $ v : acc) [] [0..] thing1 = either id id baz
The call / cc operator was introduced in the diagram when there is little experience with control operators. Now we have a lot of experience, and many serious flaws of call / cc came to light. If you are interested in more information, the next page details problems with call / cc. Argument against calling / cc
source share