on master help sign in
Drop trailing whitespace
716ce6bBryan O'Sullivan
Data/Text.hs+4−4
@@ -167,7 +167,7 @@ module Data.Text
167 , partition
167 , partition
168
168
169 -- , findSubstring
169 -- , findSubstring
170−
170+
171 -- * Indexing
171 -- * Indexing
172 -- $index
172 -- $index
173 , index
173 , index
@@ -330,7 +330,7 @@ instance NFData Text
330
330
331-- This instance preserves data abstraction at the cost of inefficiency.
331-- This instance preserves data abstraction at the cost of inefficiency.
332-- We omit reflection services for the sake of data abstraction.
332-- We omit reflection services for the sake of data abstraction.
333−--
333+--
334-- This instance was created by copying the behavior of Data.Set and
334-- This instance was created by copying the behavior of Data.Set and
335-- Data.Map. If you feel a mistake has been made, please feel free to
335-- Data.Map. If you feel a mistake has been made, please feel free to
336-- submit improvements.
336-- submit improvements.
@@ -1129,7 +1129,7 @@ findAIndexOrEnd q t@(Text _arr _off len) = go 0
1129 where go !i | i >= len || q c = i
1129 where go !i | i >= len || q c = i
1130 | otherwise = go (i+d)
1130 | otherwise = go (i+d)
1131 where Iter c d = iter t i
1131 where Iter c d = iter t i
1132−
1132+
1133-- | /O(n)/ Group characters in a string by equality.
1133-- | /O(n)/ Group characters in a string by equality.
1134group :: Text -> [Text]
1134group :: Text -> [Text]
1135group = groupBy (==)
1135group = groupBy (==)
@@ -1162,7 +1162,7 @@ tails t | null t = [empty]
1162-- > splitOn "\r\n" "a\r\nb\r\nd\r\ne" == ["a","b","d","e"]
1162-- > splitOn "\r\n" "a\r\nb\r\nd\r\ne" == ["a","b","d","e"]
1163-- > splitOn "aaa" "aaaXaaaXaaaXaaa" == ["","X","X","X",""]
1163-- > splitOn "aaa" "aaaXaaaXaaaXaaa" == ["","X","X","X",""]
1164-- > splitOn "x" "x" == ["",""]
1164-- > splitOn "x" "x" == ["",""]
1165−--
1165+--
1166-- and
1166-- and
1167--
1167--
1168-- > intercalate s . splitOn s == id
1168-- > intercalate s . splitOn s == id
Data/Text/Encoding/Error.hs+1−1
@@ -88,7 +88,7 @@ showUnicodeException (EncodeError desc (Just c))
88 = "Cannot encode character '\\x" ++ showHex (fromEnum c) ("': " ++ desc)
88 = "Cannot encode character '\\x" ++ showHex (fromEnum c) ("': " ++ desc)
89showUnicodeException (EncodeError desc Nothing)
89showUnicodeException (EncodeError desc Nothing)
90 = "Cannot encode input: " ++ desc
90 = "Cannot encode input: " ++ desc
91−
91+
92instance Show UnicodeException where
92instance Show UnicodeException where
93 show = showUnicodeException
93 show = showUnicodeException
94
94
Data/Text/Encoding/Utf8.hs+1−1
@@ -146,7 +146,7 @@ validate3 x1 x2 x3 = validate3_1 || validate3_2 || validate3_3 || validate3_4
146validate4 :: Word8 -> Word8 -> Word8 -> Word8 -> Bool
146validate4 :: Word8 -> Word8 -> Word8 -> Word8 -> Bool
147{-# INLINE validate4 #-}
147{-# INLINE validate4 #-}
148validate4 x1 x2 x3 x4 = validate4_1 || validate4_2 || validate4_3
148validate4 x1 x2 x3 x4 = validate4_1 || validate4_2 || validate4_3
149− where
149+ where
150 validate4_1 = x1 == 0xF0 &&
150 validate4_1 = x1 == 0xF0 &&
151 between x2 0x90 0xBF &&
151 between x2 0x90 0xBF &&
152 between x3 0x80 0xBF &&
152 between x3 0x80 0xBF &&
Data/Text/Fusion/Common.hs+1−1
@@ -307,7 +307,7 @@ lengthI (Stream next s0 _len) = loop_length 0 s0
307-- of 'lengthI', but can short circuit if the count of characters is
307-- of 'lengthI', but can short circuit if the count of characters is
308-- greater than the number, and hence be more efficient.
308-- greater than the number, and hence be more efficient.
309compareLengthI :: Integral a => Stream Char -> a -> Ordering
309compareLengthI :: Integral a => Stream Char -> a -> Ordering
310−compareLengthI (Stream next s0 len) n =
310+compareLengthI (Stream next s0 len) n =
311 case exactly len of
311 case exactly len of
312 Nothing -> loop_cmp 0 s0
312 Nothing -> loop_cmp 0 s0
313 Just i -> compare (fromIntegral i) n
313 Just i -> compare (fromIntegral i) n
Data/Text/IO.hs+5−5
@@ -16,7 +16,7 @@
16module Data.Text.IO
16module Data.Text.IO
17 (
17 (
18 -- * Performance
18 -- * Performance
19− -- $performance
19+ -- $performance
20
20
21 -- * Locale support
21 -- * Locale support
22 -- $locale
22 -- $locale
@@ -133,7 +133,7 @@ hGetContents h = do
133 ts <- readChunks
133 ts <- readChunks
134 (hh', _) <- hClose_help hh
134 (hh', _) <- hClose_help hh
135 return (hh'{haType=ClosedHandle}, T.concat ts)
135 return (hh'{haType=ClosedHandle}, T.concat ts)
136−
136+
137-- | Use a more efficient buffer size if we're reading in
137-- | Use a more efficient buffer size if we're reading in
138-- block-buffered mode with the default buffer size. When we can
138-- block-buffered mode with the default buffer size. When we can
139-- determine the size of the handle we're reading, set the buffer size
139-- determine the size of the handle we're reading, set the buffer size
@@ -167,7 +167,7 @@ hPutStr h = B.hPutStr h . encodeUtf8
167#else
167#else
168-- This function is lifted almost verbatim from GHC.IO.Handle.Text.
168-- This function is lifted almost verbatim from GHC.IO.Handle.Text.
169hPutStr h t = do
169hPutStr h t = do
170− (buffer_mode, nl) <-
170+ (buffer_mode, nl) <-
171 wantWritableHandle "hPutStr" h $ \h_ -> do
171 wantWritableHandle "hPutStr" h $ \h_ -> do
172 bmode <- getSpareBuffer h_
172 bmode <- getSpareBuffer h_
173 return (bmode, haOutputNL h_)
173 return (bmode, haOutputNL h_)
@@ -249,7 +249,7 @@ writeBlocksRaw h buf0 (Stream next0 s0 _len) = outer s0 buf0
249
249
250-- This function is completely lifted from GHC.IO.Handle.Text.
250-- This function is completely lifted from GHC.IO.Handle.Text.
251getSpareBuffer :: Handle__ -> IO (BufferMode, CharBuffer)
251getSpareBuffer :: Handle__ -> IO (BufferMode, CharBuffer)
252−getSpareBuffer Handle__{haCharBuffer=ref,
252+getSpareBuffer Handle__{haCharBuffer=ref,
253 haBuffers=spare_ref,
253 haBuffers=spare_ref,
254 haBufferMode=mode}
254 haBufferMode=mode}
255 = do
255 = do
@@ -270,7 +270,7 @@ getSpareBuffer Handle__{haCharBuffer=ref,
270-- This function is completely lifted from GHC.IO.Handle.Text.
270-- This function is completely lifted from GHC.IO.Handle.Text.
271commitBuffer :: Handle -> RawCharBuffer -> Int -> Int -> Bool -> Bool
271commitBuffer :: Handle -> RawCharBuffer -> Int -> Int -> Bool -> Bool
272 -> IO CharBuffer
272 -> IO CharBuffer
273−commitBuffer hdl !raw !sz !count flush release =
273+commitBuffer hdl !raw !sz !count flush release =
274 wantWritableHandle "commitAndReleaseBuffer" hdl $
274 wantWritableHandle "commitAndReleaseBuffer" hdl $
275 commitBuffer' raw sz count flush release
275 commitBuffer' raw sz count flush release
276{-# INLINE commitBuffer #-}
276{-# INLINE commitBuffer #-}
Data/Text/IO/Internal.hs+2−2
@@ -85,8 +85,8 @@ hGetLineLoop hh@Handle__{..} = go where
85maybeFillReadBuffer :: Handle__ -> CharBuffer -> IO (Maybe CharBuffer)
85maybeFillReadBuffer :: Handle__ -> CharBuffer -> IO (Maybe CharBuffer)
86maybeFillReadBuffer handle_ buf
86maybeFillReadBuffer handle_ buf
87 = catch (Just `fmap` getSomeCharacters handle_ buf) $ \e ->
87 = catch (Just `fmap` getSomeCharacters handle_ buf) $ \e ->
88− if isEOFError e
88+ if isEOFError e
89− then return Nothing
89+ then return Nothing
90 else ioError e
90 else ioError e
91
91
92unpack :: RawCharBuffer -> Int -> Int -> IO Text
92unpack :: RawCharBuffer -> Int -> Int -> IO Text
Data/Text/Lazy.hs+3−3
@@ -174,7 +174,7 @@ module Data.Text.Lazy
174 , partition
174 , partition
175
175
176 -- , findSubstring
176 -- , findSubstring
177−
177+
178 -- * Indexing
178 -- * Indexing
179 , index
179 , index
180 , count
180 , count
@@ -921,7 +921,7 @@ drop i t0
921 | otherwise = drop' i t0
921 | otherwise = drop' i t0
922 where drop' 0 ts = ts
922 where drop' 0 ts = ts
923 drop' _ Empty = Empty
923 drop' _ Empty = Empty
924− drop' n (Chunk t ts)
924+ drop' n (Chunk t ts)
925 | n < len = Chunk (T.drop (fromIntegral n) t) ts
925 | n < len = Chunk (T.drop (fromIntegral n) t) ts
926 | otherwise = drop' (n - len) ts
926 | otherwise = drop' (n - len) ts
927 where len = fromIntegral (T.length t)
927 where len = fromIntegral (T.length t)
@@ -1209,7 +1209,7 @@ tails ts@(Chunk t ts')
1209-- > splitOn "\r\n" "a\r\nb\r\nd\r\ne" == ["a","b","d","e"]
1209-- > splitOn "\r\n" "a\r\nb\r\nd\r\ne" == ["a","b","d","e"]
1210-- > splitOn "aaa" "aaaXaaaXaaaXaaa" == ["","X","X","X",""]
1210-- > splitOn "aaa" "aaaXaaaXaaaXaaa" == ["","X","X","X",""]
1211-- > splitOn "x" "x" == ["",""]
1211-- > splitOn "x" "x" == ["",""]
1212−--
1212+--
1213-- and
1213-- and
1214--
1214--
1215-- > intercalate s . splitOn s == id
1215-- > intercalate s . splitOn s == id
Data/Text/Lazy/Builder.hs+4−4
@@ -5,7 +5,7 @@
5-- Module : Data.Text.Lazy.Builder
5-- Module : Data.Text.Lazy.Builder
6-- Copyright : (c) 2010 Johan Tibell
6-- Copyright : (c) 2010 Johan Tibell
7-- License : BSD3-style (see LICENSE)
7-- License : BSD3-style (see LICENSE)
8−--
8+--
9-- Maintainer : Johan Tibell <johan.tibell@gmail.com>
9-- Maintainer : Johan Tibell <johan.tibell@gmail.com>
10-- Stability : experimental
10-- Stability : experimental
11-- Portability : portable to Hugs and GHC
11-- Portability : portable to Hugs and GHC
@@ -139,7 +139,7 @@ append (Builder f) (Builder g) = Builder (f . g)
139
139
140-- TODO: Experiment to find the right threshold.
140-- TODO: Experiment to find the right threshold.
141copyLimit :: Int
141copyLimit :: Int
142−copyLimit = 128
142+copyLimit = 128
143
143
144-- This function attempts to merge small @Text@ values instead of
144-- This function attempts to merge small @Text@ values instead of
145-- treating each value as its own chunk. We may not always want this.
145-- treating each value as its own chunk. We may not always want this.
@@ -292,14 +292,14 @@ append' (Builder f) (Builder g) = Builder (f . g)
292"append/writeAtMost" forall a b (f::forall s. A.MArray s -> Int -> ST s Int)
292"append/writeAtMost" forall a b (f::forall s. A.MArray s -> Int -> ST s Int)
293 (g::forall s. A.MArray s -> Int -> ST s Int) ws.
293 (g::forall s. A.MArray s -> Int -> ST s Int) ws.
294 append (writeAtMost a f) (append (writeAtMost b g) ws) =
294 append (writeAtMost a f) (append (writeAtMost b g) ws) =
295− append (writeAtMost (a+b) (\marr o -> f marr o >>= \ n ->
295+ append (writeAtMost (a+b) (\marr o -> f marr o >>= \ n ->
296 g marr (o+n) >>= \ m ->
296 g marr (o+n) >>= \ m ->
297 let s = n+m in s `seq` return s)) ws
297 let s = n+m in s `seq` return s)) ws
298
298
299"writeAtMost/writeAtMost" forall a b (f::forall s. A.MArray s -> Int -> ST s Int)
299"writeAtMost/writeAtMost" forall a b (f::forall s. A.MArray s -> Int -> ST s Int)
300 (g::forall s. A.MArray s -> Int -> ST s Int).
300 (g::forall s. A.MArray s -> Int -> ST s Int).
301 append (writeAtMost a f) (writeAtMost b g) =
301 append (writeAtMost a f) (writeAtMost b g) =
302− writeAtMost (a+b) (\marr o -> f marr o >>= \ n ->
302+ writeAtMost (a+b) (\marr o -> f marr o >>= \ n ->
303 g marr (o+n) >>= \ m ->
303 g marr (o+n) >>= \ m ->
304 let s = n+m in s `seq` return s)
304 let s = n+m in s `seq` return s)
305
305
Data/Text/Lazy/Encoding/Fusion.hs+1−1
@@ -5,7 +5,7 @@
5-- Copyright : (c) 2009, 2010 Bryan O'Sullivan
5-- Copyright : (c) 2009, 2010 Bryan O'Sullivan
6--
6--
7-- License : BSD-style
7-- License : BSD-style
8−-- Maintainer : bos@serpentine.com, rtomharper@googlemail.com,
8+-- Maintainer : bos@serpentine.com, rtomharper@googlemail.com,
9-- duncan@haskell.org
9-- duncan@haskell.org
10-- Stability : experimental
10-- Stability : experimental
11-- Portability : portable
11-- Portability : portable
Data/Text/Lazy/IO.hs+2−2
@@ -16,7 +16,7 @@
16module Data.Text.Lazy.IO
16module Data.Text.Lazy.IO
17 (
17 (
18 -- * Performance
18 -- * Performance
19− -- $performance
19+ -- $performance
20
20
21 -- * Locale support
21 -- * Locale support
22 -- $locale
22 -- $locale
@@ -119,7 +119,7 @@ lazyRead h = unsafeInterleaveIO $
119 case haType hh of
119 case haType hh of
120 ClosedHandle -> return (hh, L.empty)
120 ClosedHandle -> return (hh, L.empty)
121 SemiClosedHandle -> lazyReadBuffered h hh
121 SemiClosedHandle -> lazyReadBuffered h hh
122− _ -> ioException
122+ _ -> ioException
123 (IOError (Just h) IllegalOperation "hGetContents"
123 (IOError (Just h) IllegalOperation "hGetContents"
124 "illegal handle type" Nothing Nothing)
124 "illegal handle type" Nothing Nothing)
125
125
Data/Text/Lazy/Internal.hs+1−1
@@ -8,7 +8,7 @@
8-- duncan@haskell.org
8-- duncan@haskell.org
9-- Stability : experimental
9-- Stability : experimental
10-- Portability : GHC
10-- Portability : GHC
11−--
11+--
12-- A module containing private 'Text' internals. This exposes the
12-- A module containing private 'Text' internals. This exposes the
13-- 'Text' representation and low level construction functions.
13-- 'Text' representation and low level construction functions.
14-- Modules which extend the 'Text' system may need to use this module.
14-- Modules which extend the 'Text' system may need to use this module.
Data/Text/Search.hs+1−1
@@ -14,7 +14,7 @@
14-- Horspool, Sunday, and Lundh.
14-- Horspool, Sunday, and Lundh.
15--
15--
16-- References:
16-- References:
17−--
17+--
18-- * R. S. Boyer, J. S. Moore: A Fast String Searching Algorithm.
18-- * R. S. Boyer, J. S. Moore: A Fast String Searching Algorithm.
19-- Communications of the ACM, 20, 10, 762-772 (1977)
19-- Communications of the ACM, 20, 10, 762-772 (1977)
20--
20--
Data/Text/Unsafe.hs+1−1
@@ -24,7 +24,7 @@ module Data.Text.Unsafe
24 , takeWord16
24 , takeWord16
25 , dropWord16
25 , dropWord16
26 ) where
26 ) where
27−
27+
28#if defined(ASSERTS)
28#if defined(ASSERTS)
29import Control.Exception (assert)
29import Control.Exception (assert)
30#endif
30#endif
Data/Text/Unsafe/Base.hs+1−1
@@ -15,7 +15,7 @@ module Data.Text.Unsafe.Base
15 inlineInterleaveST
15 inlineInterleaveST
16 , inlinePerformIO
16 , inlinePerformIO
17 ) where
17 ) where
18−
18+
19import GHC.ST (ST(..))
19import GHC.ST (ST(..))
20#if defined(__GLASGOW_HASKELL__)
20#if defined(__GLASGOW_HASKELL__)
21# if __GLASGOW_HASKELL__ >= 611
21# if __GLASGOW_HASKELL__ >= 611
benchmarks/haskell/Benchmarks/Programs/StripTags.hs+1−1
@@ -14,7 +14,7 @@
14module Benchmarks.Programs.StripTags
14module Benchmarks.Programs.StripTags
15 ( benchmark
15 ( benchmark
16 ) where
16 ) where
17−
17+
18import Criterion (Benchmark, bgroup, bench)
18import Criterion (Benchmark, bgroup, bench)
19import Data.List (mapAccumL)
19import Data.List (mapAccumL)
20import System.IO (Handle, hPutStr)
20import System.IO (Handle, hPutStr)
benchmarks/haskell/Benchmarks/ReadNumbers.hs+1−1
@@ -88,7 +88,7 @@ text reader = foldl' go 1000000
88 where
88 where
89 go z t = case reader t of Left _ -> z
89 go z t = case reader t of Left _ -> z
90 Right (n, _) -> min n z
90 Right (n, _) -> min n z
91−
91+
92byteString :: (Ord a, Num a) => (t -> Maybe (a,t)) -> [t] -> a
92byteString :: (Ord a, Num a) => (t -> Maybe (a,t)) -> [t] -> a
93byteString reader = foldl' go 1000000
93byteString reader = foldl' go 1000000
94 where
94 where
cbits/cbits.c+1−1
@@ -47,7 +47,7 @@ static const uint8_t utf8d[] = {
47 12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12,
47 12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12,
48 12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12,
48 12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12,
49 12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12,
49 12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12,
50− 12,36,12,12,12,12,12,12,12,12,12,12,
50+ 12,36,12,12,12,12,12,12,12,12,12,12,
51};
51};
52
52
53static inline uint32_t
53static inline uint32_t
scripts/Arsec.hs+1−1
@@ -26,7 +26,7 @@ import Text.ParserCombinators.Parsec.Prim hiding ((<|>), many)
26instance Applicative (GenParser s a) where
26instance Applicative (GenParser s a) where
27 pure = return
27 pure = return
28 (<*>) = ap
28 (<*>) = ap
29−
29+
30instance Alternative (GenParser s a) where
30instance Alternative (GenParser s a) where
31 empty = mzero
31 empty = mzero
32 (<|>) = mplus
32 (<|>) = mplus
tests/Tests/QuickCheckUtils.hs+6−6
@@ -24,7 +24,7 @@ module Tests.QuickCheckUtils
24 , eqP
24 , eqP
25
25
26 , Encoding (..)
26 , Encoding (..)
27−
27+
28 , write_read
28 , write_read
29 ) where
29 ) where
30
30
@@ -67,7 +67,7 @@ genUnicode = fmap fromString string where
67 string = sized $ \n ->
67 string = sized $ \n ->
68 do k <- choose (0,n)
68 do k <- choose (0,n)
69 sequence [ char | _ <- [1..k] ]
69 sequence [ char | _ <- [1..k] ]
70−
70+
71 excluding :: [a -> Bool] -> Gen a -> Gen a
71 excluding :: [a -> Bool] -> Gen a -> Gen a
72 excluding bad gen = loop
72 excluding bad gen = loop
73 where
73 where
@@ -76,14 +76,14 @@ genUnicode = fmap fromString string where
76 if or (map ($ x) bad)
76 if or (map ($ x) bad)
77 then loop
77 then loop
78 else return x
78 else return x
79−
79+
80 reserved = [lowSurrogate, highSurrogate, noncharacter]
80 reserved = [lowSurrogate, highSurrogate, noncharacter]
81 lowSurrogate c = c >= 0xDC00 && c <= 0xDFFF
81 lowSurrogate c = c >= 0xDC00 && c <= 0xDFFF
82 highSurrogate c = c >= 0xD800 && c <= 0xDBFF
82 highSurrogate c = c >= 0xD800 && c <= 0xDBFF
83 noncharacter c = masked == 0xFFFE || masked == 0xFFFF
83 noncharacter c = masked == 0xFFFE || masked == 0xFFFF
84 where
84 where
85− masked = c .&. 0xFFFF
85+ masked = c .&. 0xFFFF
86−
86+
87 ascii = choose (0,0x7F)
87 ascii = choose (0,0x7F)
88 plane0 = choose (0xF0, 0xFFFF)
88 plane0 = choose (0xF0, 0xFFFF)
89 plane1 = oneof [ choose (0x10000, 0x10FFF)
89 plane1 = oneof [ choose (0x10000, 0x10FFF)
@@ -109,7 +109,7 @@ genUnicode = fmap fromString string where
109 ]
109 ]
110 plane14 = choose (0xE0000, 0xE0FFF)
110 plane14 = choose (0xE0000, 0xE0FFF)
111 planes = [ascii, plane0, plane1, plane2, plane14]
111 planes = [ascii, plane0, plane1, plane2, plane14]
112−
112+
113 char = chr `fmap` excluding reserved (oneof planes)
113 char = chr `fmap` excluding reserved (oneof planes)
114
114
115-- For tests that have O(n^2) running times or input sizes, resize
115-- For tests that have O(n^2) running times or input sizes, resize
text.cabal+2−2
@@ -3,7 +3,7 @@ version: 0.11.2.2
3homepage: https://github.com/bos/text
3homepage: https://github.com/bos/text
4bug-reports: https://github.com/bos/text/issues
4bug-reports: https://github.com/bos/text/issues
5synopsis: An efficient packed Unicode text type.
5synopsis: An efficient packed Unicode text type.
6−description:
6+description:
7 .
7 .
8 An efficient packed, immutable Unicode text type (both strict and
8 An efficient packed, immutable Unicode text type (both strict and
9 lazy), with a powerful loop fusion optimization framework.
9 lazy), with a powerful loop fusion optimization framework.
@@ -148,7 +148,7 @@ library
148 else
148 else
149 cpp-options: -DINTEGER_GMP
149 cpp-options: -DINTEGER_GMP
150 build-depends: integer-gmp >= 0.2 && < 0.5
150 build-depends: integer-gmp >= 0.2 && < 0.5
151−
151+
152
152
153 if impl(ghc >= 6.9) && impl(ghc < 6.11)
153 if impl(ghc >= 6.9) && impl(ghc < 6.11)
154 cpp-options: -DINTEGER_GMP
154 cpp-options: -DINTEGER_GMP