Re: [Haskell-cafe] named pipe interface

2012-01-16 Thread Serge D. Mechveliani
To my question about safety of >> toA_IO = openFd "toA" WriteOnly Nothing defaultFileFlags >> fromA_IO = openFd "fromA" ReadOnly Nothing defaultFileFlags >> toA = unsafePerformIO toA_IO >> fromA = unsafePerformIO fromA_IO >> >> axiomIO :: String -> IO String >> axiomIO str = do >>

Re: [Haskell-cafe] named pipe interface

2012-01-16 Thread Jean-Marie Gaillourdet
Hi, On 14.01.2012, at 12:11, Serge D. Mechveliani wrote: > On Fri, Jan 13, 2012 at 12:19:34PM -0800, Donn Cave wrote: >> Quoth "Serge D. Mechveliani" , >> ... >>> Initially, I did the example by the Foreign Function Interface for C. >>> But then, I thought "But this is unnatural! Use plainly the

Re: [Haskell-cafe] named pipe interface

2012-01-14 Thread Brandon Allbery
On Sat, Jan 14, 2012 at 11:57, Donn Cave wrote: > I don't know. When I was younger, I used to track these problems down > and try to explain in detail why buffered I/O is a bad bet with pipes, > sockets etc. I don't think anyone listened. I think I am going to > experiment with "I am old, so l

Re: [Haskell-cafe] named pipe interface

2012-01-14 Thread Donn Cave
Quoth "Serge D. Mechveliani" , > By openFile you, probably, mean openFd. Yes, sorry! > Another point is the number of open files, for a long loop. ... > toA_IO = openFd "toA" WriteOnly Nothing defaultFileFlags ... > When applying axiomIO in a loop of 9000 strings, it breaks: > "too ma

Re: [Haskell-cafe] named pipe interface

2012-01-14 Thread Serge D. Mechveliani
On Fri, Jan 13, 2012 at 12:19:34PM -0800, Donn Cave wrote: > Quoth "Serge D. Mechveliani" , > ... > > Initially, I did the example by the Foreign Function Interface for C. > > But then, I thought "But this is unnatural! Use plainly the standard > > Haskell IO, it has everything". > > > > So, your a

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Donn Cave
Quoth "Serge D. Mechveliani" , ... > Initially, I did the example by the Foreign Function Interface for C. > But then, I thought "But this is unnatural! Use plainly the standard > Haskell IO, it has everything". > > So, your advice is "return to FFI" ? Well, it turns out that the I/O system functi

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Serge D. Mechveliani
On Fri, Jan 13, 2012 at 04:34:37PM +0100, Chadda?? Fouch?? wrote: > On Thu, Jan 12, 2012 at 7:53 PM, Serge D. Mechveliani > wrote: > > [..] > > I need to organize a  string interface  for a Haskell function > > Main.axiom  and a C program > >                            fifoFromA.c > > > > via a p

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Brandon Allbery
On Fri, Jan 13, 2012 at 13:23, Michael Craig wrote: > Brandon, can you elaborate? Are you talking about UNIX named pipes or > FIFO/queue data structures in general? I mean POSIX named pipes. They work, but they don't do what most people think they do, and they're rather annoying to work with i

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Serge D. Mechveliani
On Fri, Jan 13, 2012 at 10:08:04AM -0800, Donn Cave wrote: > Quoth "Serge D. Mechveliani" , > [ ... why in Haskell instead of FFI ... ] > > > Because it is a direct and the simplest approach. Why does one need a > > foreign language, if all the needed functions are in the standard > > Haskell lib

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Serge D. Mechveliani
I (Sergei) am invesigating (so far) only Unix named pipes. > > I hope you are aware of the many "gotchas" involved with FIFOs. > > There are very good reasons why they are not widely used. At least in C <-> C, the Unix named pipes do work. And I am trying to replace the first end with Haskell.

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Michael Craig
Brandon, can you elaborate? Are you talking about UNIX named pipes or FIFO/queue data structures in general? Mike Craig On Fri, Jan 13, 2012 at 12:39 PM, Brandon Allbery wrote: > On Fri, Jan 13, 2012 at 12:25, Serge D. Mechveliani wrote: > >> On Fri, Jan 13, 2012 at 04:34:37PM +0100, Chadda??

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Donn Cave
Quoth "Serge D. Mechveliani" , [ ... why in Haskell instead of FFI ... ] > Because it is a direct and the simplest approach. Why does one need a > foreign language, if all the needed functions are in the standard > Haskell library? The GHC Haskell library makes some compromises with normal I/O f

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Brandon Allbery
On Fri, Jan 13, 2012 at 12:25, Serge D. Mechveliani wrote: > On Fri, Jan 13, 2012 at 04:34:37PM +0100, Chadda?? Fouch?? wrote: > > Now that seems interesting, but just to be clear : did you choose > > this solution (and why won't you use the FFI instead) or is this just > > to see how to work it

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Serge D. Mechveliani
On Fri, Jan 13, 2012 at 04:34:37PM +0100, Chadda?? Fouch?? wrote: > On Thu, Jan 12, 2012 at 7:53 PM, Serge D. Mechveliani > wrote: > > People, > > > > (I wonder: is this for  beginn...@haskell.org ?) > > I don't think so. > > > > > I need to organize a  string interface  for a Haskell function

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Chaddaï Fouché
On Thu, Jan 12, 2012 at 7:53 PM, Serge D. Mechveliani wrote: > People, > > (I wonder: is this for  beginn...@haskell.org ?) I don't think so. > > I need to organize a  string interface  for a Haskell function > Main.axiom  and a C program >                            fifoFromA.c > > via a pair o

Re: [Haskell-cafe] named pipe interface

2012-01-12 Thread Donn Cave
Quoth "Serge D. Mechveliani" , > (I wonder: is this for beginn...@haskell.org ?) No, not really! As already mentioned, the use of UnsafePerformIO goes a little beyond what I think is its intended purpose, and I think you might have better luck here with a test program that illustrates the probl

Re: [Haskell-cafe] named pipe interface

2012-01-12 Thread Steffen Schuldenzucker
On 01/12/2012 07:53 PM, Serge D. Mechveliani wrote: [...] > For the "to-A" part writen in C (instead of Haskell), this interface loop works all right. With Haskell, I manage to process only a single string in the loop, and then it ends with an error. Main.hs is given below. I never dealt w

[Haskell-cafe] named pipe interface

2012-01-12 Thread Serge D. Mechveliani
People, (I wonder: is this for beginn...@haskell.org ?) I need to organize a string interface for a Haskell function Main.axiom and a C program fifoFromA.c via a pair of named pipes (in Linux, UNIX). The pipes are created before running, by the commands