[Haskell-beginners] Re: Network programming (select(2)) for Haskell?

Paolo Losi paolo.losi at gmail.com
Fri Sep 10 09:19:44 EDT 2010

Hi Patrick,

On 10/09/2010 14:02, Patrick LeBoutillier wrote:
> In order to get better at network programming using haskell, I'd like
> to try and port it to Haskell, but I can't seem to locate the
> equivalent to select(2) in Haskell. Perhaps a different idiom is to be
> used?

No select(2) syscall is explicitly available at API level.
This is because of how the Haskell (GHC) Runtime is structured.
Both the default single threaded runtime that the multi-threaded
runtime are capable of hosting different haskell light-threads.
IO between lightweight threads is multiplex transparently
by the runtime via select(2) o epoll/kqueue in the upcoming ghc.
Haskell lightweight threads are very cheap and efficient
so the idiomatic way to handle your use case is to spawn different
threads with forkIO (you are forking lightweight threads not OS thread)
and you some Haskell concurrency primitive for thread
communication/synchronization (see MVar and Chan in Control.Concurrent).


More information about the Beginners mailing list