Refactor my code, in fact I should name the code "wing man", they help each 
other to accomplish the job.
spawn = callCC $ \k -> do

  let suspend = callCC $ \c -> do
                  let f x = c (f, x)
                  k (f, "ready!")

  lift $ putStrLn "begin capture current continuation ..."

  (r, s) <- suspend

  lift $ putStrLn ("can we be here1? -- " ++ s)

  (r, s) <- suspend

  lift $ putStrLn ("can we be here2? -- " ++ s)

  (r, s) <- suspend

  lift $ putStrLn ("can we be here3? -- " ++ s)

  return (r, "kkkk")

wingman = (`runContT` return) $ do
  lift $ putStrLn "alpha"

  (k, s) <- spawn

  lift $ putStrLn ("in fun1 -- " ++ s)

  lift $ Thread.sleep (2000L)
  k "I try to pass some string here"

  lift $ putStrLn "no chance to be there"



-- 
You received this message because you are subscribed to the Google Groups 
"Frege Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to frege-programming-language+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to