Created
September 8, 2013 22:18
-
-
Save mmitou/6488953 to your computer and use it in GitHub Desktop.
ファイル表示
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
| {-# 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