You can ask GHCI for information about these types --
>> :i FD
type FD = Foreign.C.Types.CInt
>> :i Fd
newtype Fd = Fd Foreign.C.Types.CInt
so they are essentially identical, except that one is a newtype
and the other is a type
. So the conversion functions are (I recommend choosing better names)
convert :: FD -> Fd
convert = Fd
convert' :: Fd -> FD
convert' (Fd x) = x
RE your question about converting from IO (IO Handle, IO Handle)
to IO (Handle,Handle)
you could do this explicitly
flatten :: IO (IO a, IO a) -> IO (a,a)
flatten x = do
(a,b) <- x
a' <- a
b' <- b
return (a', b')
but a better way would be to avoid creatign the IO (IO Handle, IO Handle)
in the first place. Since your types are
openPseudoTerminal :: IO (Fd, Fd)
fdToHandle :: FD -> IO Handle
you could do
getHandles :: IO (Handle, Handle)
getHandles = do
(Fd a, Fd b) <- openPseudoTerminal
a' <- fdToHandle a
b' <- fdToHandle b
return (a', b')