[Haskell-cafe] named pipe interface

Donn Cave donn at avvanta.com
Fri Jan 13 21:19:34 CET 2012

Quoth "Serge D. Mechveliani" <mechvel at 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 functions in System.Posix.IO
may work for your purposes.  I was able to get your example to work
with these functions, which correspond to open(2), read(2), write(2).

I would also use these functions in C, as you did in your C program.
Haskell I/O functions like hGetLine are analogous to C library I/O
like fgets(3) - in particular, they're buffered, and I would guess
that's why they don't work for you here.

   openFile "toA" WriteOnly Nothing defaultFileFlags
   openFile "fromA" ReadOnly Nothing defaultFileFlags

   fdWrite toA str
   (str, len) <- fdRead fromA 64
   return str


More information about the Haskell-Cafe mailing list