[Haskell-cafe] Continuations
Bulat Ziganshin
bulatz at HotPOP.com
Fri Dec 23 08:06:12 EST 2005
Hello Joel,
Friday, December 23, 2005, 12:49:19 PM, you wrote:
JR> My current setup involves threads that block on a MVar/TMVar until
JR> they read an event from it and then proceed. I would like to convert
JR> these threads into continuations whereby a continuation is saved when
JR> an event is requested and I can call that continuation when an even
JR> arrives.
hm... you are waste much time unsystematically "optimizing"
random-selected parts of program. now it's time to stop jumping and
start thinking
the main mprovements drained by changing algorithms and not
implementation details. profiling is only toold to know your program
better but it can't replace careful planning and global vision. what
you really need - is to ask questions about your global program
structure instead of jumping between large number of techniques
what you want to buy with continuations and, more important, why you
need it?
JR> Alternatively, I would appreciate an example that requests, say, two
JR> Ints by saving a continuation each time and returns the sum.
do a <- readLn :: IO Int
b <- readLn :: IO Int
return (a+b)
or equivalent code
readLn :: IO Int >>= \a ->
readLn :: IO Int >>= \b ->
return (a+b)
amazed? :)
--
Best regards,
Bulat mailto:bulatz at HotPOP.com
More information about the Haskell-Cafe
mailing list