[Haskell-cafe] learning Haskell
Bulat Ziganshin
bulat.ziganshin at gmail.com
Fri Feb 9 16:38:22 EST 2007
Hello,
i'd a discussion in russian programmer's forum (rsdn.ru) about
haskell and learning it. one interesting point was that imperative
programmers imagine that multi-threading programming should require
special knowledges. they was really amazed when i showed the following
program that creates thread and interacts with it - without locks,
semaphores, synchronized access and all other old stuff
-- Thread, that cyclically read commands from channel, and executes them
graphThread c = do cmd <- getChan c
cmd
graphThread c
-- Creates graphThread and sends a few commands to it for execution
main = do c <- newChan
forkOS $ graphThread c
putChan c (print "Hi")
tid <- forkOS $ putChan c (print "Hi from other thread")
putChan c (print "Bye")
waitThread tid
i think that some example like it would be appropriate in haskell book
for *novices* - just because it's easy to do in Haskell. so, i vote
for adding Multi-threading chapter to such books (and it may be
especially important nowadays when everyone are crazy about
multi-cores :)
--
Best regards,
Bulat mailto:Bulat.Ziganshin at gmail.com
More information about the Haskell-Cafe
mailing list