on master help sign in
Implement fromChunks and toChunks.
445a34fBryan O'Sullivan
Data/Text/Lazy.hs+10
@@ -38,6 +38,8 @@ module Data.Text.Lazy
38 , unpack
38 , unpack
39 , singleton
39 , singleton
40 , empty
40 , empty
41+ , fromChunks
42+ , toChunks
41
43
42 -- * Basic interface
44 -- * Basic interface
43 , cons
45 , cons
@@ -203,6 +205,14 @@ singleton c = Chunk (T.singleton c) Empty
203 unstream (S.singleton c) = singleton c
205 unstream (S.singleton c) = singleton c
204 #-}
206 #-}
205
207
208+-- | /O(c)/ Convert a list of strict 'T.Text's into a lazy 'Text'.
209+fromChunks :: [T.Text] -> Text
210+fromChunks cs = L.foldr chunk Empty cs
211+
212+-- | /O(n)/ Convert a lazy 'Text' into a list of strict 'T.Text's.
213+toChunks :: Text -> [T.Text]
214+toChunks cs = foldrChunks (:) [] cs
215+
206cons :: Char -> Text -> Text
216cons :: Char -> Text -> Text
207cons c t = Chunk (T.singleton c) t
217cons c t = Chunk (T.singleton c) t
208{-# INLINE [1] cons #-}
218{-# INLINE [1] cons #-}