on master help sign in
Some tidyup and Haddocks.

--HG-- extra : convert_revision : b7e83b0ed19ed6403586e6d4d972c25627737f83

commit995448218c094d87aaf65ba752a802c28b4d99d5 authorBryan O'Sullivan <bos@serpentine.com> dateTue 27 Jan 2009, 04:46 (18 years ago) parenta986b8c
7 files changed+127−32
Data/Text.hs+14−14 Data/Text/Array.hs+1−1 Data/Text/Fusion.hs+49−13 Data/Text/UnsafeChar.hs+15−2 Data/Text/Utf16.hs+14−1 Data/Text/Utf32.hs+13 Data/Text/Utf8.hs+21−1
Data/Text.hs+14−14
@@ -103,29 +103,29 @@ module Data.Text
103103 , readFile
104104 ) where
105105
106−import Prelude (Char,Bool,Int,Maybe,String,
107− Eq,(==),(++),error,
108− Show,showsPrec,
109− Read,readsPrec,
110− (&&),(||),(+),(-),(<),(>),(<=),(>=),(.),(>>=),
111− return,otherwise,
106+import Prelude (Char, Bool, Int, Maybe, String,
107+ Eq, (==), (++), error,
108+ Show, showsPrec,
109+ Read, readsPrec,
110+ (&&), (||), (+), (-), (<), (>), (<=), (>=), (.), (>>=),
111+ return, otherwise,
112112 IO, FilePath)
113113import Data.Char (isSpace)
114−import Control.Monad.ST(ST)
114+import Control.Monad.ST (ST)
115115import qualified Data.Text.Array as A
116116import qualified Data.ByteString as B
117−import Data.ByteString(ByteString)
117+import Data.ByteString (ByteString)
118118import qualified Data.List as L
119−import Data.Monoid(Monoid(..))
120−import Data.Word(Word16)
119+import Data.Monoid (Monoid(..))
120+import Data.Word (Word16)
121121import Data.String (IsString(..))
122122
123123import qualified Data.Text.Fusion as S
124−import Data.Text.Fusion (Stream(..),Step(..),Encoding(..),
125− stream,unstream,stream_bs,unstream_bs,restream)
126−import Data.Text.Internal(Text(..),empty)
124+import Data.Text.Fusion (Stream(..), Step(..), Encoding(..),
125+ stream, unstream, stream_bs, unstream_bs, restream)
126+import Data.Text.Internal (Text(..), empty)
127127import qualified Prelude as P
128−import Data.Text.UnsafeChar(unsafeChr)
128+import Data.Text.UnsafeChar (unsafeChr)
129129import qualified Data.Text.Utf16 as U16
130130
131131-- $fusion
Data/Text/Array.hs+1−1
@@ -60,7 +60,7 @@ import Hugs.ST (ST(..), runST)
6060# error not implemented for this compiler
6161#endif
6262
63−import Data.Typeable
63+import Data.Typeable (Typeable1(..), Typeable2(..), TyCon, mkTyCon, mkTyConApp)
6464import Data.Word (Word16)
6565import Prelude hiding (length, read)
6666
Data/Text/Fusion.hs+49−13
@@ -1,16 +1,34 @@
11{-# LANGUAGE ExistentialQuantification, BangPatterns, MagicHash #-}
22
3+-- |
4+-- Module : Data.Text.Fusion
5+-- Copyright : (c) Tom Harper 2008-2009,
6+-- (c) Bryan O'Sullivan 2009,
7+-- (c) Duncan Coutts 2009
8+--
9+-- License : BSD-style
10+-- Maintainer : rtharper@aftereternity.co.uk, bos@serpentine.com,
11+-- duncan@haskell.org
12+-- Stability : experimental
13+-- Portability : GHC
14+--
15+-- Text manipulation functions represented as fusible operations over
16+-- streams.
317module Data.Text.Fusion
418 (
19+ -- * Types
520 Stream(..)
621 , Step(..)
722 , Encoding(..)
23+
24+ -- * Creation and elimination
825 , stream
926 , unstream
1027 , stream_bs
1128 , unstream_bs
1229 , restream
13− , eq
30+
31+ -- * Basic interface
1432 , cons
1533 , snoc
1634 , append
@@ -20,32 +38,50 @@ module Data.Text.Fusion
2038 , init
2139 , null
2240 , length
41+ , eq
42+
43+ -- * Transformations
2344 , map
45+ , intersperse
46+
47+ -- * Folds
2448 , foldl
2549 , foldl'
2650 , foldl1
2751 , foldl1'
2852 , foldr
2953 , foldr1
54+
55+ -- ** Special folds
3056 , concat
3157 , concatMap
3258 , any
3359 , all
3460 , maximum
3561 , minimum
62+
63+ -- * Construction
3664 , unfoldr
3765 , unfoldrN
66+
67+ -- * Substrings
68+ -- ** Breaking strings
3869 , take
3970 , drop
4071 , takeWhile
4172 , dropWhile
73+
74+ -- * Searching
4275 , elem
43− , find
4476 , filter
45− , intersperse
77+
78+ -- * Indexing
79+ , find
4680 , index
4781 , findIndex
4882 , elemIndex
83+
84+ -- * Zipping and unzipping
4985 , zipWith
5086 ) where
5187
@@ -54,21 +90,21 @@ import Prelude hiding
5490 foldl1, foldr1, concatMap, any, all, maximum, minimum, take, drop,
5591 takeWhile, dropWhile, elem, zipWith)
5692import Data.Char (ord)
57−import Control.Exception(assert)
58−import Control.Monad(liftM2)
59−import Control.Monad.ST(runST,ST)
93+import Control.Exception (assert)
94+import Control.Monad (liftM2)
95+import Control.Monad.ST (runST, ST)
6096import Data.Bits (shiftL, shiftR, (.&.))
6197import qualified Data.ByteString as B
6298import qualified Data.ByteString.Unsafe as B
63−import Data.ByteString.Internal(ByteString(..),mallocByteString,memcpy)
99+import Data.ByteString.Internal (ByteString(..), mallocByteString, memcpy)
64100import qualified Data.List as L
65−import Data.Word(Word8, Word16, Word32)
66−import Foreign.ForeignPtr(withForeignPtr,ForeignPtr)
67−import Foreign.Storable(pokeByteOff)
101+import Data.Word (Word8, Word16, Word32)
102+import Foreign.ForeignPtr (withForeignPtr, ForeignPtr)
103+import Foreign.Storable (pokeByteOff)
68104import GHC.Exts (Int(..), (+#))
69−import System.IO.Unsafe(unsafePerformIO)
70−import Data.Text.Internal(Text(..),empty)
71−import Data.Text.UnsafeChar(unsafeChr,unsafeChr8,unsafeChr32)
105+import System.IO.Unsafe (unsafePerformIO)
106+import Data.Text.Internal (Text(..), empty)
107+import Data.Text.UnsafeChar (unsafeChr, unsafeChr8, unsafeChr32)
72108import qualified Data.Text.Array as A
73109import qualified Data.Text.Utf8 as U8
74110import qualified Data.Text.Utf16 as U16
Data/Text/UnsafeChar.hs+15−2
@@ -1,5 +1,18 @@
11{-# LANGUAGE MagicHash #-}
22
3+-- |
4+-- Module : Data.Text.UnsafeChar
5+-- Copyright : (c) Tom Harper 2008-2009,
6+-- (c) Bryan O'Sullivan 2009,
7+-- (c) Duncan Coutts 2009
8+--
9+-- License : BSD-style
10+-- Maintainer : rtharper@aftereternity.co.uk, bos@serpentine.com,
11+-- duncan@haskell.org
12+-- Stability : experimental
13+-- Portability : GHC
14+--
15+-- Fast character manipulation function.
316module Data.Text.UnsafeChar
417 (
518 unsafeChr
@@ -7,8 +20,8 @@ module Data.Text.UnsafeChar
720 , unsafeChr32
821 ) where
922
10−import GHC.Exts
11−import GHC.Word
23+import GHC.Exts (Char(..), chr#, word2Int#)
24+import GHC.Word (Word8(..), Word16(..), Word32(..))
1225
1326unsafeChr :: Word16 -> Char
1427unsafeChr (W16# w#) = C# (chr# (word2Int# w#))
Data/Text/Utf16.hs+14−1
@@ -1,8 +1,21 @@
11{-# LANGUAGE MagicHash #-}
22
3+-- |
4+-- Module : Data.Text.Utf16
5+-- Copyright : (c) Tom Harper 2008-2009,
6+-- (c) Bryan O'Sullivan 2009,
7+-- (c) Duncan Coutts 2009
8+--
9+-- License : BSD-style
10+-- Maintainer : rtharper@aftereternity.co.uk, bos@serpentine.com,
11+-- duncan@haskell.org
12+-- Stability : experimental
13+-- Portability : GHC
14+--
15+-- Basic UTF-16 validation and character manipulation.
316module Data.Text.Utf16
417 (
5− chr2
18+ chr2
619 , validate1
720 , validate2
821 ) where
Data/Text/Utf32.hs+13
@@ -1,3 +1,16 @@
1+-- |
2+-- Module : Data.Text.Utf16
3+-- Copyright : (c) Tom Harper 2008-2009,
4+-- (c) Bryan O'Sullivan 2009,
5+-- (c) Duncan Coutts 2009
6+--
7+-- License : BSD-style
8+-- Maintainer : rtharper@aftereternity.co.uk, bos@serpentine.com,
9+-- duncan@haskell.org
10+-- Stability : experimental
11+-- Portability : portable
12+--
13+-- Basic UTF-32 validation.
114module Data.Text.Utf32
215 (
316 validate
Data/Text/Utf8.hs+21−1
@@ -1,12 +1,29 @@
11{-# LANGUAGE MagicHash #-}
2+
3+-- |
4+-- Module : Data.Text.Utf16
5+-- Copyright : (c) Tom Harper 2008-2009,
6+-- (c) Bryan O'Sullivan 2009,
7+-- (c) Duncan Coutts 2009
8+--
9+-- License : BSD-style
10+-- Maintainer : rtharper@aftereternity.co.uk, bos@serpentine.com,
11+-- duncan@haskell.org
12+-- Stability : experimental
13+-- Portability : GHC
14+--
15+-- Basic UTF-8 validation and character manipulation.
216module Data.Text.Utf8
317 (
18+ -- Decomposition
419 ord2
520 , ord3
621 , ord4
22+ -- Construction
723 , chr2
824 , chr3
925 , chr4
26+ -- * Validation
1027 , validate1
1128 , validate2
1229 , validate3
@@ -18,7 +35,10 @@ import Data.Bits (shiftR, (.&.))
1835import GHC.Exts
1936import GHC.Word (Word8(..))
2037
21−between :: Word8 -> Word8 -> Word8 -> Bool
38+between :: Word8 -- ^ byte to check
39+ -> Word8 -- ^ lower bound
40+ -> Word8 -- ^ upper bound
41+ -> Bool
2242between x y z = x >= y && x <= z
2343{-# INLINE between #-}
2444