@@ -39,6 +39,7 @@ data Text = Text
39 {-# UNPACK #-} !Int -- length
39 {-# UNPACK #-} !Int -- length
40 deriving (Typeable)
40 deriving (Typeable)
42+-- | Smart constructor.
42text :: A.Array Word16 -> Int -> Int -> Text
43text :: A.Array Word16 -> Int -> Int -> Text
43text arr off len =
44text arr off len =
44 assert (len >= 0) .
45 assert (len >= 0) .
@@ -55,6 +56,7 @@ empty :: Text
55empty = Text A.empty 0 0
56empty = Text A.empty 0 0
56{-# INLINE [1] empty #-}
57{-# INLINE [1] empty #-}
59+-- | A useful 'show'-like function for debugging purposes.
58showText :: Text -> String
60showText :: Text -> String
59showText (Text arr off len) =
61showText (Text arr off len) =
60 "Text " ++ (show . take (off+len) . A.toList) arr ++ ' ' :
62 "Text " ++ (show . take (off+len) . A.toList) arr ++ ' ' :