Commits

Bryan O'Sullivan committed 184faa4

Implement fromChunks and toChunks.

  • Participants
  • Parent commits a92e75a

Comments (0)

Files changed (1)

File Data/Text/Lazy.hs

     , unpack
     , singleton
     , empty
+    , fromChunks
+    , toChunks
 
     -- * Basic interface
     , cons
     unstream (S.singleton c) = singleton c
   #-}
 
+-- | /O(c)/ Convert a list of strict 'T.Text's into a lazy 'Text'.
+fromChunks :: [T.Text] -> Text
+fromChunks cs = L.foldr chunk Empty cs
+
+-- | /O(n)/ Convert a lazy 'Text' into a list of strict 'T.Text's.
+toChunks :: Text -> [T.Text]
+toChunks cs = foldrChunks (:) [] cs
+
 cons :: Char -> Text -> Text
 cons c t = Chunk (T.singleton c) t
 {-# INLINE [1] cons #-}