Add Handle type with scope parameter
- Dominant language
- Haskell
- Stars
- 25
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
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.
```haskell
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
```
https://github.com/haskell/bytestring/pull/708
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.