on master help sign in
Stub out definitions for >= 6.12.
31e4e5dBryan O'Sullivan
Data/Text/IO.hs+37
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
1-- |
2-- |
2-- Module : Data.Text.IO
3-- Module : Data.Text.IO
3-- Copyright : (c) Bryan O'Sullivan 2009
4-- Copyright : (c) Bryan O'Sullivan 2009
@@ -34,46 +35,82 @@ import Data.Text (Text)
34import Prelude hiding (appendFile, getContents, getLine, interact, putStr,
35import Prelude hiding (appendFile, getContents, getLine, interact, putStr,
35 putStrLn, readFile, writeFile)
36 putStrLn, readFile, writeFile)
36import System.IO (Handle, hPutChar, stdin, stdout)
37import System.IO (Handle, hPutChar, stdin, stdout)
38+#if __GLASGOW_HASKELL__ <= 610
37import qualified Data.ByteString as B
39import qualified Data.ByteString as B
38import Data.Text.Encoding (decodeUtf8, encodeUtf8)
40import Data.Text.Encoding (decodeUtf8, encodeUtf8)
41+#else
42+import GHC.IO.Handle.Internals (wantWritableHandle)
43+#endif
39
44
40-- | The 'readFile' function reads a file and returns the contents of
45-- | The 'readFile' function reads a file and returns the contents of
41-- the file as a string. The entire file is read strictly, as with
46-- the file as a string. The entire file is read strictly, as with
42-- 'getContents'.
47-- 'getContents'.
43readFile :: FilePath -> IO Text
48readFile :: FilePath -> IO Text
49+#if __GLASGOW_HASKELL__ <= 610
44readFile = fmap decodeUtf8 . B.readFile
50readFile = fmap decodeUtf8 . B.readFile
51+#else
52+readFile = undefined
53+#endif
45
54
46-- | Write a string to a file. The file is truncated to zero length
55-- | Write a string to a file. The file is truncated to zero length
47-- before writing begins.
56-- before writing begins.
48writeFile :: FilePath -> Text -> IO ()
57writeFile :: FilePath -> Text -> IO ()
58+#if __GLASGOW_HASKELL__ <= 610
49writeFile p = B.writeFile p . encodeUtf8
59writeFile p = B.writeFile p . encodeUtf8
60+#else
61+writeFile = undefined
62+#endif
50
63
51-- | Write a string the end of a file.
64-- | Write a string the end of a file.
52appendFile :: FilePath -> Text -> IO ()
65appendFile :: FilePath -> Text -> IO ()
66+#if __GLASGOW_HASKELL__ <= 610
53appendFile p = B.appendFile p . encodeUtf8
67appendFile p = B.appendFile p . encodeUtf8
68+#else
69+appendFile = undefined
70+#endif
54
71
55-- | Read the remaining contents of a handle as a string.
72-- | Read the remaining contents of a handle as a string.
56hGetContents :: Handle -> IO Text
73hGetContents :: Handle -> IO Text
74+#if __GLASGOW_HASKELL__ <= 610
57hGetContents = fmap decodeUtf8 . B.hGetContents
75hGetContents = fmap decodeUtf8 . B.hGetContents
76+#else
77+hGetContents = undefined
78+#endif
58
79
59-- | Read a single line from a handle.
80-- | Read a single line from a handle.
60hGetLine :: Handle -> IO Text
81hGetLine :: Handle -> IO Text
82+#if __GLASGOW_HASKELL__ <= 610
61hGetLine = fmap decodeUtf8 . B.hGetLine
83hGetLine = fmap decodeUtf8 . B.hGetLine
84+#else
85+hGetLine = undefined
86+#endif
62
87
63-- | Write a string to a handle.
88-- | Write a string to a handle.
64hPutStr :: Handle -> Text -> IO ()
89hPutStr :: Handle -> Text -> IO ()
90+#if __GLASGOW_HASKELL__ <= 610
65hPutStr h = B.hPutStr h . encodeUtf8
91hPutStr h = B.hPutStr h . encodeUtf8
92+#else
93+hPutStr h t = undefined
94+#endif
66
95
67-- | Write a string to a handle, followed by a newline.
96-- | Write a string to a handle, followed by a newline.
68hPutStrLn :: Handle -> Text -> IO ()
97hPutStrLn :: Handle -> Text -> IO ()
98+#if __GLASGOW_HASKELL__ <= 610
69hPutStrLn h t = B.hPutStrLn h (encodeUtf8 t) >> hPutChar h '\n'
99hPutStrLn h t = B.hPutStrLn h (encodeUtf8 t) >> hPutChar h '\n'
100+#else
101+hPutStrLn h t = undefined
102+#endif
70
103
71-- | The 'interact' function takes a function of type @Text -> Text@
104-- | The 'interact' function takes a function of type @Text -> Text@
72-- as its argument. The entire input from the standard input device is
105-- as its argument. The entire input from the standard input device is
73-- passed to this function as its argument, and the resulting string
106-- passed to this function as its argument, and the resulting string
74-- is output on the standard output device.
107-- is output on the standard output device.
75interact :: (Text -> Text) -> IO ()
108interact :: (Text -> Text) -> IO ()
109+#if __GLASGOW_HASKELL__ <= 610
76interact f = B.interact (encodeUtf8 . f . decodeUtf8)
110interact f = B.interact (encodeUtf8 . f . decodeUtf8)
111+#else
112+interact f = undefined
113+#endif
77
114
78-- | Read all user input on 'stdin' as a single string.
115-- | Read all user input on 'stdin' as a single string.
79getContents :: IO Text
116getContents :: IO Text