on master help sign in
Fix up some documentation.
2c4a9c7Bryan O'Sullivan
Data/Text/Lazy/IO.hs+8−7
@@ -8,7 +8,7 @@
8-- Stability : experimental
8-- Stability : experimental
9-- Portability : GHC
9-- Portability : GHC
10--
10--
11−-- Efficient locale-sensitive support for text I\/O.
11+-- Efficient locale-sensitive support for lazy text I\/O.
12
12
13module Data.Text.Lazy.IO
13module Data.Text.Lazy.IO
14 (
14 (
@@ -56,9 +56,8 @@ import System.IO.Error (isEOFError)
56import System.IO.Unsafe (unsafeInterleaveIO)
56import System.IO.Unsafe (unsafeInterleaveIO)
57#endif
57#endif
58
58
59−-- | The 'readFile' function reads a file and returns the contents of
59+-- | Read a file and return its contents as a string. The file is
60−-- the file as a string. The entire file is read strictly, as with
61−-- 'getContents'.
60+-- read lazily, as with 'getContents'.
62readFile :: FilePath -> IO Text
61readFile :: FilePath -> IO Text
63readFile name = openFile name ReadMode >>= hGetContents
62readFile name = openFile name ReadMode >>= hGetContents
64
63
@@ -71,6 +70,8 @@ writeFile p = withFile p WriteMode . flip hPutStr
71appendFile :: FilePath -> Text -> IO ()
70appendFile :: FilePath -> Text -> IO ()
72appendFile p = withFile p AppendMode . flip hPutStr
71appendFile p = withFile p AppendMode . flip hPutStr
73
72
73+-- | Lazily read the remaining contents of a 'Handle'. The 'Handle'
74+-- will be closed after the read completes, or on error.
74hGetContents :: Handle -> IO Text
75hGetContents :: Handle -> IO Text
75#if __GLASGOW_HASKELL__ <= 610
76#if __GLASGOW_HASKELL__ <= 610
76hGetContents = fmap decodeUtf8 . L8.hGetContents
77hGetContents = fmap decodeUtf8 . L8.hGetContents
@@ -122,12 +123,12 @@ hPutStrLn h t = hPutStr h t >> hPutChar h '\n'
122
123
123-- | The 'interact' function takes a function of type @Text -> Text@
124-- | The 'interact' function takes a function of type @Text -> Text@
124-- as its argument. The entire input from the standard input device is
125-- as its argument. The entire input from the standard input device is
125−-- passed to this function as its argument, and the resulting string
126+-- passed (lazily) to this function as its argument, and the resulting
126−-- is output on the standard output device.
127+-- string is output on the standard output device.
127interact :: (Text -> Text) -> IO ()
128interact :: (Text -> Text) -> IO ()
128interact f = putStr . f =<< getContents
129interact f = putStr . f =<< getContents
129
130
130−-- | Read all user input on 'stdin' as a single string.
131+-- | Lazily read all user input on 'stdin' as a single string.
131getContents :: IO Text
132getContents :: IO Text
132getContents = hGetContents stdin
133getContents = hGetContents stdin
133
134