
On Wed, 2008-07-02 at 02:07 -0400, Brandon S. Allbery KF8NH wrote:
On 2008 Jul 2, at 1:42, Galchin, Vasili wrote:
errno <- throwErrnoIfMinus1 "aioError" (c_aio_error p_aiocb)
"ghc" thinks that "Errno" should be an instance of "Num":
System/Posix/Aio.hsc:117:15: No instance for (Num Errno)
I expect so it can compare it to -1(throwErrnoIfMinusOne). But if the return value is actually an errno and not -1 to indicate error (which it is if I read the manpage correctly), you don't want throwErrnoIfMinus1 anyway; I suspect you want to wrap the return value of c_aio_return (which should be IO CInt) in an Errno constructor, then use errnoToIOError if you really want to raise an IOError.
(What were you expecting for "count"? I see none, just an errno.)
Note that it *never* returns -1; it returns 0 for successful completion for the aiocb, EINPROGRESS if it's still working, and the appropriate errno if it failed.
It seems as though it can return -1 if given non-sensical input. But in that case, the nicely type-correct thing to do would still be to have the C binding return a CInt, and wrap that after the call to throwErrnoIfMinus1 (in this case, `errno' still refers to the global errno, set to EINVAL). jcc