Commits

Bryan O'Sullivan committed 4762cdc

Some tidyup and Haddocks.

Comments (0)

Files changed (7)

     , readFile
     ) where
 
-import Prelude (Char,Bool,Int,Maybe,String,
-                Eq,(==),(++),error,
-                Show,showsPrec,
-                Read,readsPrec,
-                (&&),(||),(+),(-),(<),(>),(<=),(>=),(.),(>>=),
-                return,otherwise,
+import Prelude (Char, Bool, Int, Maybe, String,
+                Eq, (==), (++), error,
+                Show, showsPrec,
+                Read, readsPrec,
+                (&&), (||), (+), (-), (<), (>), (<=), (>=), (.), (>>=),
+                return, otherwise,
                 IO, FilePath)
 import Data.Char (isSpace)
-import Control.Monad.ST(ST)
+import Control.Monad.ST (ST)
 import qualified Data.Text.Array as A
 import qualified Data.ByteString as B
-import Data.ByteString(ByteString)
+import Data.ByteString (ByteString)
 import qualified Data.List as L
-import Data.Monoid(Monoid(..))
-import Data.Word(Word16)
+import Data.Monoid (Monoid(..))
+import Data.Word (Word16)
 import Data.String (IsString(..))
 
 import qualified Data.Text.Fusion as S
-import Data.Text.Fusion (Stream(..),Step(..),Encoding(..),
-                    stream,unstream,stream_bs,unstream_bs,restream)
-import Data.Text.Internal(Text(..),empty)
+import Data.Text.Fusion (Stream(..), Step(..), Encoding(..),
+                         stream, unstream, stream_bs, unstream_bs, restream)
+import Data.Text.Internal (Text(..), empty)
 import qualified Prelude as P
-import Data.Text.UnsafeChar(unsafeChr)
+import Data.Text.UnsafeChar (unsafeChr)
 import qualified Data.Text.Utf16 as U16
 
 -- $fusion

Data/Text/Array.hs

 # error not implemented for this compiler
 #endif
 
-import Data.Typeable
+import Data.Typeable (Typeable1(..), Typeable2(..), TyCon, mkTyCon, mkTyConApp)
 import Data.Word (Word16)
 import Prelude hiding (length, read)
 

Data/Text/Fusion.hs

 {-# LANGUAGE ExistentialQuantification, BangPatterns, MagicHash #-}
 
+-- |
+-- Module      : Data.Text.Fusion
+-- Copyright   : (c) Tom Harper 2008-2009,
+--               (c) Bryan O'Sullivan 2009,
+--               (c) Duncan Coutts 2009
+--
+-- License     : BSD-style
+-- Maintainer  : rtharper@aftereternity.co.uk, bos@serpentine.com,
+--               duncan@haskell.org
+-- Stability   : experimental
+-- Portability : GHC
+--
+-- Text manipulation functions represented as fusible operations over
+-- streams.
 module Data.Text.Fusion
     (
+    -- * Types
       Stream(..)
     , Step(..)
     , Encoding(..)
+
+    -- * Creation and elimination
     , stream
     , unstream
     , stream_bs
     , unstream_bs
     , restream
-    , eq
+
+    -- * Basic interface
     , cons
     , snoc
     , append
     , init
     , null
     , length
+    , eq
+
+    -- * Transformations
     , map
+    , intersperse
+
+    -- * Folds
     , foldl
     , foldl'
     , foldl1
     , foldl1'
     , foldr
     , foldr1
+
+    -- ** Special folds
     , concat
     , concatMap
     , any
     , all
     , maximum
     , minimum
+
+    -- * Construction
     , unfoldr
     , unfoldrN
+
+    -- * Substrings
+    -- ** Breaking strings
     , take
     , drop
     , takeWhile
     , dropWhile
+
+    -- * Searching
     , elem
+    , filter
+
+    -- * Indexing
     , find
-    , filter
-    , intersperse
     , index
     , findIndex
     , elemIndex
+
+    -- * Zipping and unzipping
     , zipWith
     ) where
 
      foldl1, foldr1, concatMap, any, all, maximum, minimum, take, drop,
      takeWhile, dropWhile, elem, zipWith)
 import Data.Char (ord)
-import Control.Exception(assert)
-import Control.Monad(liftM2)
-import Control.Monad.ST(runST,ST)
+import Control.Exception (assert)
+import Control.Monad (liftM2)
+import Control.Monad.ST (runST, ST)
 import Data.Bits (shiftL, shiftR, (.&.))
 import qualified Data.ByteString as B
 import qualified Data.ByteString.Unsafe as B
-import Data.ByteString.Internal(ByteString(..),mallocByteString,memcpy)
+import Data.ByteString.Internal (ByteString(..), mallocByteString, memcpy)
 import qualified Data.List as L
-import Data.Word(Word8, Word16, Word32)
-import Foreign.ForeignPtr(withForeignPtr,ForeignPtr)
-import Foreign.Storable(pokeByteOff)
+import Data.Word (Word8, Word16, Word32)
+import Foreign.ForeignPtr (withForeignPtr, ForeignPtr)
+import Foreign.Storable (pokeByteOff)
 import GHC.Exts (Int(..), (+#))
-import System.IO.Unsafe(unsafePerformIO)
-import Data.Text.Internal(Text(..),empty)
-import Data.Text.UnsafeChar(unsafeChr,unsafeChr8,unsafeChr32)
+import System.IO.Unsafe (unsafePerformIO)
+import Data.Text.Internal (Text(..), empty)
+import Data.Text.UnsafeChar (unsafeChr, unsafeChr8, unsafeChr32)
 import qualified Data.Text.Array as A
 import qualified Data.Text.Utf8 as U8
 import qualified Data.Text.Utf16 as U16

Data/Text/UnsafeChar.hs

 {-# LANGUAGE MagicHash #-}
 
+-- |
+-- Module      : Data.Text.UnsafeChar
+-- Copyright   : (c) Tom Harper 2008-2009,
+--               (c) Bryan O'Sullivan 2009,
+--               (c) Duncan Coutts 2009
+--
+-- License     : BSD-style
+-- Maintainer  : rtharper@aftereternity.co.uk, bos@serpentine.com,
+--               duncan@haskell.org
+-- Stability   : experimental
+-- Portability : GHC
+--
+-- Fast character manipulation function.
 module Data.Text.UnsafeChar
     (
       unsafeChr
     , unsafeChr32
     ) where
 
-import GHC.Exts
-import GHC.Word
+import GHC.Exts (Char(..), chr#, word2Int#)
+import GHC.Word (Word8(..), Word16(..), Word32(..))
 
 unsafeChr :: Word16 -> Char
 unsafeChr (W16# w#) = C# (chr# (word2Int# w#))

Data/Text/Utf16.hs

 {-# LANGUAGE MagicHash #-}
 
+-- |
+-- Module      : Data.Text.Utf16
+-- Copyright   : (c) Tom Harper 2008-2009,
+--               (c) Bryan O'Sullivan 2009,
+--               (c) Duncan Coutts 2009
+--
+-- License     : BSD-style
+-- Maintainer  : rtharper@aftereternity.co.uk, bos@serpentine.com,
+--               duncan@haskell.org
+-- Stability   : experimental
+-- Portability : GHC
+--
+-- Basic UTF-16 validation and character manipulation.
 module Data.Text.Utf16
     (
-     chr2
+      chr2
     , validate1
     , validate2
     ) where

Data/Text/Utf32.hs

+-- |
+-- Module      : Data.Text.Utf16
+-- Copyright   : (c) Tom Harper 2008-2009,
+--               (c) Bryan O'Sullivan 2009,
+--               (c) Duncan Coutts 2009
+--
+-- License     : BSD-style
+-- Maintainer  : rtharper@aftereternity.co.uk, bos@serpentine.com,
+--               duncan@haskell.org
+-- Stability   : experimental
+-- Portability : portable
+--
+-- Basic UTF-32 validation.
 module Data.Text.Utf32
     (
       validate

Data/Text/Utf8.hs

 {-# LANGUAGE MagicHash #-}
+
+-- |
+-- Module      : Data.Text.Utf16
+-- Copyright   : (c) Tom Harper 2008-2009,
+--               (c) Bryan O'Sullivan 2009,
+--               (c) Duncan Coutts 2009
+--
+-- License     : BSD-style
+-- Maintainer  : rtharper@aftereternity.co.uk, bos@serpentine.com,
+--               duncan@haskell.org
+-- Stability   : experimental
+-- Portability : GHC
+--
+-- Basic UTF-8 validation and character manipulation.
 module Data.Text.Utf8
     (
+    -- Decomposition
       ord2
     , ord3
     , ord4
+    -- Construction
     , chr2
     , chr3
     , chr4
+    -- * Validation
     , validate1
     , validate2
     , validate3
 import GHC.Exts
 import GHC.Word (Word8(..))
 
-between :: Word8 -> Word8 -> Word8 -> Bool
+between :: Word8                -- ^ byte to check
+        -> Word8                -- ^ lower bound
+        -> Word8                -- ^ upper bound
+        -> Bool
 between x y z = x >= y && x <= z
 {-# INLINE between #-}