Last active
August 29, 2015 14:05
-
-
Save carymrobbins/1f46f351d43964668aff to your computer and use it in GitHub Desktop.
I was under the impression that ResourceT prevents accessing released resources with the type system. Maybe I am not using it correctly...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Control.Monad.Trans.Class (lift) | |
| import Control.Monad.Trans.Resource | |
| import System.IO | |
| main = runResourceT $ do | |
| (releaseO, output) <- allocate (openFile "output.txt" WriteMode) hClose | |
| lift $ hPutStrLn output "hallo!" | |
| release releaseO | |
| (releaseI, input) <- allocate (openFile "output.txt" ReadMode) hClose | |
| release releaseI | |
| -- Too bad the next call doesn't cause a type error... | |
| lift $ putStr "Contents: " >> hGetContents input >>= hPutStrLn output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment