Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Data/Text/Internal/Builder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module Data.Text.Internal.Builder
Builder
, toLazyText
, toLazyTextWith
, toText

-- ** Constructing Builders
, singleton
Expand Down Expand Up @@ -231,6 +232,10 @@ toLazyTextWith :: Int -> Builder -> L.Text
toLazyTextWith chunkSize m = L.fromChunks (runST $
newBuffer chunkSize >>= runBuilder (m `append` flush) (const (return [])))

-- | /O(n)./ Extract a strict @Text@ from a @Builder@.
toText :: Builder -> Text
toText = L.toStrict . toLazyText

-- | /O(1)./ Pop the strict @Text@ we have constructed so far, if any,
-- yielding a new chunk in the result lazy @Text@.
flush :: Builder
Expand Down
1 change: 1 addition & 0 deletions src/Data/Text/Lazy/Builder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module Data.Text.Lazy.Builder
Builder
, toLazyText
, toLazyTextWith
, toText

-- * Constructing Builders
, singleton
Expand Down