Difference between revisions of "Implement a chat server"
Revision as of 21:19, 14. like the following:
-- in the imports our Main
First, let's import the module:
import Control.Concurrent.Chan -- at the top of Main.hs with the others,
liftM and
fix which you can learn more about here and here, respectively. In short,
liftM allows us to elegantly lift a function over some structure, while
fix allows us to define a Monadic fixpoint.
-- at the top of Main.hs import Control.Monad (lift <- liftM init (hGetLine hdl) broadcast line loop
Notice how
runConn, running in a separate thread from our main one, now!