safer-file-handles-0.11: Type-safe file handling

MaintainerBas van Dijk <>



Unsafe functions for retrieving the native Handle from a regional file handle and for lifting operations on Handles to RegionalFileHandles.

These operations are unsafe because they allow you to close regional file handles before exiting their region. So they enable you to perform IO with already closed handles.



unsafeHandle :: FileHandle handle => handle ioMode r -> Handle ioModeSource

wrap :: (FileHandle handle, MonadIO m) => (Handle ioMode -> IO α) -> handle ioMode r -> m αSource

wrap2 :: (FileHandle handle, MonadIO m) => (Handle ioMode -> β -> IO α) -> handle ioMode r -> β -> m αSource

wrap3 :: (FileHandle handle, MonadIO m) => (Handle ioMode -> γ -> β -> IO α) -> handle ioMode r -> γ -> β -> m αSource

sanitizeIOError :: IO α -> IO αSource

Modify thrown IOErrors in the given computation by erasing the ioe_handle field in the IOError which may contain the Handle which caused the IOError.

I use this to ensure that Handles don't leak out the region via exceptions.