
Hello! I need to get the file descriptors of some handles, but the handles should not be modified. They should not be closed by the operation. I guess, that the handle gets closed for a reason. But I'm using the revealed file descriptors in a way which should pose no problems for the integrity of the GHC library. In order to make a non-closing handleToFd function, I'm studying GHC's library source code. But there's a lot which I can't make much sense, because it uses non-standard language features (GHC extensions), which I'm not familiar with. I don't mean you to explain these GHC extensions to me. I just want to give an impression of the problems I encounter: 1. data FD = FD { fdFD :: {-# UNPACK #-} !CInt, fdIsNonBlocking :: {-# UNPACK #-} !Int } What is that exclamation mark? And that "{-# UNPACK #-}"? 2. handleToFd' :: Handle -> Handle__ -> IO (Handle__, Fd) handleToFd' h h_@Handle__{haType=_,..} = do case cast haDevice of -- ... haDevice should be a function. How could you cast it? 3. data Handle__ = forall dev enc_state dec_state . (IODevice dev, BufferedIO dev, Typeable dev) => Handle__ { -- ... } deriving Typeable What's that "forall" thing? 4. handleToFd' h h_@Handle__{haType=_,..} = do case cast haDevice of Nothing -> -- ... Just fd -> do -- ... return (Handle__{haType=ClosedHandle,..}, Fd (fromIntegral (FD.fdFD fd))) What's this ".." inside "Handle__{haType=ClosedHandle,..}"? If anyone can point out to me, how this non-blocking handleToFd function should be made, I would be grateful. Greetings Volker Wysk