Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save mmitou/6488953 to your computer and use it in GitHub Desktop.
ファイル表示
{-# LANGUAGE ScopedTypeVariables #-}
import System.IO
import Control.Monad
import Control.Exception
printFile :: FilePath -> IO ()
printFile filePath = do
h <- openFile filePath ReadMode
x <- hGetContents h
putStrLn x
hClose h
return ()
printFile' :: FilePath -> IO ()
printFile' filePath = withFile filePath ReadMode
$ \h -> hGetContents h >>= putStrLn
printFile'' :: FilePath -> IO ()
printFile'' filePath = bracket (openFile filePath ReadMode)
hClose
(\h -> hGetContents h >>= putStrLn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment