-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
withBinaryFile
and openBinaryFile
produce Handle values with different semantic and they should live in different types, e.g. using hClose
on Handle from withBinaryFile
is a runtime error.
data Scope = With | Free deriving (Show, Eq)
newtype Handle (s :: Scope) = Handle IO.Handle deriving (Show, Eq)
hClose :: Handle Free -> IO ()
hClose (Handle h) = IO.hClose h
mkFreeHandle :: IO.Handle -> Handle Free
mkFreeHandle = Handle
openBinaryFile :: OsPath -> IOMode -> IO (Handle Free)
withBinaryFile :: NFData r => OsPath -> IOMode -> (Handle With -> IO r) -> IO r
Metadata
Metadata
Assignees
Labels
No labels