Re: [Haskell-cafe] Replacing stdin from within Haskell

2011-06-12 Thread Richard O'Keefe
On 11/06/2011, at 3:42 AM, Brandon Allbery wrote: On Fri, Jun 10, 2011 at 00:36, Richard O'Keefe o...@cs.otago.ac.nz wrote: The point is that they *could* have. The fact that they do not has nothing whatever to do with UNIX. It was a Haskell design decision. I have this feeling you're

Re: [Haskell-cafe] Replacing stdin from within Haskell

2011-06-10 Thread Alexander Kjeldaas
On 10 June 2011 06:43, Richard O'Keefe o...@cs.otago.ac.nz wrote: On 10/06/2011, at 1:11 AM, Erik Hesselink wrote: On Thu, Jun 9, 2011 at 13:40, Neil Davies semanticphilosop...@gmail.com wrote: Anyone out there got an elegant solution to being able to fork a haskell thread and replace

Re: [Haskell-cafe] Replacing stdin from within Haskell

2011-06-10 Thread Brandon Allbery
On Fri, Jun 10, 2011 at 00:36, Richard O'Keefe o...@cs.otago.ac.nz wrote: The point is that they *could* have.   The fact that they do not has nothing whatever to do with UNIX.  It was a Haskell design decision. I have this feeling you're looking at it backwards... The question was whether GHC

[Haskell-cafe] Replacing stdin from within Haskell

2011-06-09 Thread Neil Davies
Hi 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

Re: [Haskell-cafe] Replacing stdin from within Haskell

2011-06-09 Thread Erik Hesselink
On Thu, Jun 9, 2011 at 13:40, Neil Davies semanticphilosop...@gmail.com wrote: Anyone out there got an elegant solution to being able to fork a haskell thread and replace its 'stdin' ? If you don't mind being tied to GHC you can use hDuplicateTo from GHC.IO.Handle [1]. You can also use dupTo

Re: [Haskell-cafe] Replacing stdin from within Haskell

2011-06-09 Thread Donn Cave
Quoth Erik Hesselink hessel...@gmail.com, On Thu, Jun 9, 2011 at 13:40, Neil Davies semanticphilosop...@gmail.com wrote: Anyone out there got an elegant solution to being able to fork a haskell thread and replace its 'stdin' ? If you don't mind being tied to GHC you can use hDuplicateTo

Re: [Haskell-cafe] Replacing stdin from within Haskell

2011-06-09 Thread Erik Hesselink
On Thu, Jun 9, 2011 at 16:40, Donn Cave d...@avvanta.com wrote: Quoth Erik Hesselink hessel...@gmail.com, On Thu, Jun 9, 2011 at 13:40, Neil Davies semanticphilosop...@gmail.com wrote: Anyone out there got an elegant solution to being able to fork a haskell thread and replace its 'stdin' ?

Re: [Haskell-cafe] Replacing stdin from within Haskell

2011-06-09 Thread Brandon Allbery
On Thu, Jun 9, 2011 at 07:40, Neil Davies semanticphilosop...@gmail.com wrote: Anyone out there got an elegant solution to being able to fork a haskell thread and replace its 'stdin' ? File descriptors/file handles are per process, not per thread, on (almost?) every OS ghc supports. You'll

Re: [Haskell-cafe] Replacing stdin from within Haskell

2011-06-09 Thread Neil Davies
Thanks That is what I thought. I'll stick with what I'm doing at present which is to use temporary files - don't want to get into separate processes which I then have to co-ordinate. Cheers Neil On 9 Jun 2011, at 17:01, Brandon Allbery wrote: On Thu, Jun 9, 2011 at 07:40, Neil Davies

Re: [Haskell-cafe] Replacing stdin from within Haskell

2011-06-09 Thread Henning Thielemann
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

Re: [Haskell-cafe] Replacing stdin from within Haskell

2011-06-09 Thread Richard O'Keefe
On 9 Jun 2011, at 17:01, Brandon Allbery wrote: On Thu, Jun 9, 2011 at 07:40, Neil Davies semanticphilosop...@gmail.com wrote: Anyone out there got an elegant solution to being able to fork a haskell thread and replace its 'stdin' ? File descriptors/file handles are per process, not

Re: [Haskell-cafe] Replacing stdin from within Haskell

2011-06-09 Thread Brandon Allbery
On Thu, Jun 9, 2011 at 23:59, Richard O'Keefe o...@cs.otago.ac.nz wrote: I understood the OP's question to mean does Haskell allow rebinding of what _it_ calls standard input, which would be YES for Pop, Ada, Prolog, and Lisp, just as it is NO for C. But none of those are Haskell, and neither

Re: [Haskell-cafe] Replacing stdin from within Haskell

2011-06-09 Thread Richard O'Keefe
On 10/06/2011, at 4:12 PM, Brandon Allbery wrote: On Thu, Jun 9, 2011 at 23:59, Richard O'Keefe o...@cs.otago.ac.nz wrote: I understood the OP's question to mean does Haskell allow rebinding of what _it_ calls standard input, which would be YES for Pop, Ada, Prolog, and Lisp, just as it is

Re: [Haskell-cafe] Replacing stdin from within Haskell

2011-06-09 Thread Richard O'Keefe
On 10/06/2011, at 1:11 AM, Erik Hesselink wrote: On Thu, Jun 9, 2011 at 13:40, Neil Davies semanticphilosop...@gmail.com wrote: Anyone out there got an elegant solution to being able to fork a haskell thread and replace its 'stdin' ? If you don't mind being tied to GHC you can use