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 mech...@botik.ru, ... Initially, I did the example by the Foreign Function Interface for C. But then, I thought But this is unnatural! Use plainly

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 fdWrite toA str

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 mech...@botik.ru, ... 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

Re: [Haskell-cafe] named pipe interface

2012-01-14 Thread Donn Cave
Quoth Serge D. Mechveliani mech...@botik.ru, 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:

Re: [Haskell-cafe] named pipe interface

2012-01-14 Thread Brandon Allbery
On Sat, Jan 14, 2012 at 11:57, Donn Cave d...@avvanta.com 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

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Chaddaï Fouché
On Thu, Jan 12, 2012 at 7:53 PM, Serge D. Mechveliani mech...@botik.ru 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

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 mech...@botik.ru 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

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Brandon Allbery
On Fri, Jan 13, 2012 at 12:25, Serge D. Mechveliani mech...@botik.ruwrote: 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

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Donn Cave
Quoth Serge D. Mechveliani mech...@botik.ru, [ ... 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

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 allber...@gmail.comwrote: On Fri, Jan 13, 2012 at 12:25, Serge D. Mechveliani mech...@botik.ruwrote: On Fri, Jan 13,

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. On

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 mech...@botik.ru, [ ... 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

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Brandon Allbery
On Fri, Jan 13, 2012 at 13:23, Michael Craig mks...@gmail.com 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

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 mech...@botik.ru wrote: [..] I need to organize a  string interface  for a Haskell function Main.axiom  and a C program                            fifoFromA.c via

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Donn Cave
Quoth Serge D. Mechveliani mech...@botik.ru, ... 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

[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

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

Re: [Haskell-cafe] named pipe interface

2012-01-12 Thread Donn Cave
Quoth Serge D. Mechveliani mech...@botik.ru, (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