[Haskell-cafe] Replacing stdin from within Haskell

Henning Thielemann lemming at henning-thielemann.de
Thu Jun 9 20:43:37 CEST 2011

On Thu, 9 Jun 2011, Neil Davies wrote:

> Anyone out there got an elegant solution to being able to fork a haskell thread and replace its 'stdin' ?
> Why do I want this - well I'm using the pcap library and I want to uncompress data to feed into 'openOffile' (which will take "-" to designate read from stdin). Yes I can create a separate command and use the stuff in System.Process or uncompress it into a temporary file - but that all seems in-elegant.

I think the clean solution is to have a parameter of type Handle, that the 
threads use for reading, instead of reading from stdin. Or pass the data 
from stdin in a lazy String.

More information about the Haskell-Cafe mailing list