diff --git a/ghc/lib/posix/PosixUtil.lhs b/ghc/lib/posix/PosixUtil.lhs
index 047b9bce0ae287d473a360a617fc9f350616f88c..2b3c0d335d84bf3d311dfaeb628b403901691222 100644
--- a/ghc/lib/posix/PosixUtil.lhs
+++ b/ghc/lib/posix/PosixUtil.lhs
@@ -43,6 +43,9 @@ instance Eq Fd where
 -- use with care.
 intToFd :: Int -> Fd
 intToFd (I# fd#) = FD# fd#
+
+fdToInt :: Fd -> Int
+fdToInt (FD# x#) = I# x#
 \end{code}
 
 Now some local functions that shouldn't go outside this library.