[Haskell-cafe] How to dynamically attach readers to streams?

Marc Weber marco-oweber at gmx.de
Sun Jun 10 12:28:34 EDT 2007


Example:

main = readFile "/dev/input/mouse" >>= mapM print . streamToEvents

That's no easy.

Now I want to listen to those events remotely using a network conncetion
Data.Network does provide everything I need.

Is this done by substituting the print function with something like
sent event = do writers <- getWritersFromMVar
                mapM (sent event) writers

and using another lightweight thread to add writers/connections to the
MVar?

Would you implement this in another way?

Marc


More information about the Haskell-Cafe mailing list