Skip to content

Instantly share code, notes, and snippets.

@mmitou
Created September 8, 2013 22:40
Show Gist options
  • Select an option

  • Save mmitou/6489165 to your computer and use it in GitHub Desktop.

Select an option

Save mmitou/6489165 to your computer and use it in GitHub Desktop.
import Control.Monad.Trans.Resource(runResourceT, allocate, release)
import Control.Monad.IO.Class(liftIO)
import System.IO
printFile :: FilePath -> IO ()
printFile filePath = runResourceT $ do
(releaseKey, resource) <- allocate (openFile filePath ReadMode) hClose
liftIO (hGetContents resource >>= putStrLn)
release releaseKey
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment