How to get the file descriptor of a handle?

Jeremy Shaw jeremy at
Sat Feb 13 19:58:43 EST 2010


In GHC 6.12 there is no guarantee that a Handle is backed up by a file  
descriptor. That said,  check out the handleToFd defined on line 141  

A better type might be:

handleToFd :: Handle -> IO (Maybe Fd)

instead of raising an exception. Having a Handle not backed by a Fd is  
not really an 'exceptional' condition after all.

- jeremy

On Feb 13, 2010, at 6:23 AM, Volker Wysk wrote:

> Hello
> I'd like to know how you get the file descriptor, which is  
> incapsulated in a handle. The libraries GHC.IO.Handle/ 
> GHC.IO.Handle.FD only provide for the other direction.
> The function haFD, which I've used before I've updated to the  
> current version of GHC (6.12), appears to be in use two times in the  
> libraries. But there isn't a definition anywhere.
> Any help would be appreciated.
> Cheers,
> Volker
> -- 
> Volker Wysk <pf3 at>
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at

More information about the Glasgow-haskell-users mailing list