Keep in mind that a State monad won't necessarily play nicely with a multithreaded server. In particular, each new connection will have its state set at the point the state was at when the server started, and modifications from each child thread will be discarded. (That's assuming you do something like using monad-control.) Depending on your actual needs, you may instead want to store the priority queue in some kind of a mutable variable, so that the child threads are able to update the state for other threads.


On Fri, Jul 18, 2014 at 4:15 PM, Павел Гаврилов <lghtfck@gmail.com> wrote:
Hi!

I have:

runUnixServer (serverSettings socket) $ \appData ->
  appSource appData
  $$ CL.map handleBS
  =$ appSink appData

I  want to store some data in priority queue in Monad.State and be able to access it inside the handleBS (now: handleBS :: ByteString -> ByteString). Can you send me on the right path?

Thanx, Pavel.



_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe