Re: [Haskell-cafe] using an external application

2007-11-02 Thread Stuart Cook
On 11/2/07, Petr Hoffmann [EMAIL PROTECTED] wrote: import System.Cmd main = do System.Cmd.system echo hello output.txt -- use the external application to create an output file o1 - readFile output.txt System.Cmd.system echo bye output.txt -- the second call to

Re: [Haskell-cafe] using an external application

2007-11-02 Thread Bas van Dijk
On 11/2/07, Petr Hoffmann [EMAIL PROTECTED] wrote: I'm solving the following problem - I need to use an external application - give it the input data and receive its output. Check out: The HSH library: HSH is designed to let you mix and match shell expressions with Haskell programs. With HSH,

Re: [Haskell-cafe] using an external application

2007-11-02 Thread Henning Thielemann
On Fri, 2 Nov 2007, Petr Hoffmann wrote: Hi, I'm solving the following problem - I need to use an external application - give it the input data and receive its output. However, when multiple calls are made, the results are not as expected. The simplified version of the problem is given

Re: [Haskell-cafe] using an external application

2007-11-02 Thread Andrew Butterfield
On 11/2/07, Petr Hoffmann [EMAIL PROTECTED] wrote: import System.Cmd main = do System.Cmd.system echo hello output.txt -- use the external application to create an output file o1 - readFile output.txt System.Cmd.system echo bye output.txt -- the second call to

Re: [Haskell-cafe] using an external application

2007-11-02 Thread Jules Bean
Can you please give me some hint to solve this problem? I'm a beginning haskell developer and I'm still a bit confused by the IO monad. Other people have explained to the OP why unsafe lazy IO is breaking his code. Yet another piece of evidence, in my opinion, that unsafe-lazy-by-default is

Re: [Haskell-cafe] using an external application

2007-11-02 Thread Ketil Malde
Andrew Butterfield [EMAIL PROTECTED] writes: I'm puzzled - when I run this on GHCi (v6.4, Windows XP) I get the following outcome^^ The process cannot access the file because it is being used by another process. Isnt' this a difference between Windows and

Re: [Haskell-cafe] using an external application

2007-11-02 Thread Bulat Ziganshin
Hello Petr, Friday, November 2, 2007, 11:17:23 AM, you wrote: o1 - readFile output.txt add return $! length o1 here to evaluate whole list System.Cmd.system echo bye output.txt -- the second call to -- Best regards, Bulatmailto:[EMAIL

Re: [Haskell-cafe] using an external application

2007-11-02 Thread jerzy . karczmarczuk
Petr Hoffmann writes: I'm solving the following problem - I need to use an external application - give it the input data and receive its output. However, when multiple calls are made, the results are not as expected. The simplified version of the problem is given below:

[Haskell-cafe] using an external application

2007-11-02 Thread Petr Hoffmann
Hi, I'm solving the following problem - I need to use an external application - give it the input data and receive its output. However, when multiple calls are made, the results are not as expected. The simplified version of the problem is given below: import System.Cmd main = do

Re: [Haskell-cafe] using an external application

2007-11-02 Thread Felipe Lessa
On 11/2/07, Stuart Cook [EMAIL PROTECTED] wrote: The solution would be to use a version of readFile that works in a stricter way, by reading the file when it's told to, but I don't have an implementation handy. I guess this does the job: readFile' fp = do contents - readFile fp let ret

Re: [Haskell-cafe] using an external application

2007-11-02 Thread Henning Thielemann
On Fri, 2 Nov 2007, Felipe Lessa wrote: On 11/2/07, Stuart Cook [EMAIL PROTECTED] wrote: The solution would be to use a version of readFile that works in a stricter way, by reading the file when it's told to, but I don't have an implementation handy. I guess this does the job:

Re: [Haskell-cafe] using an external application

2007-11-02 Thread Stuart Cook
On 11/2/07, Andrew Butterfield [EMAIL PROTECTED] wrote: I'm puzzled - when I run this on GHCi (v6.4, Windows XP) I get the following outcome *Mainmain The process cannot access the file because it is being used by another process. hello *Main Under GHCi 6.6 I get this: *Main main bye

Re: [Haskell-cafe] using an external application

2007-11-02 Thread Don Stewart
lemming: On Fri, 2 Nov 2007, Felipe Lessa wrote: On 11/2/07, Stuart Cook [EMAIL PROTECTED] wrote: The solution would be to use a version of readFile that works in a stricter way, by reading the file when it's told to, but I don't have an implementation handy. I guess this does