Quoth "Serge D. Mechveliani" <[email protected]>,
...
> 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.
Specifically,
openFile "toA" WriteOnly Nothing defaultFileFlags
openFile "fromA" ReadOnly Nothing defaultFileFlags
fdWrite toA str
(str, len) <- fdRead fromA 64
return str
Donn
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe