Îõ³h&1£0…-      !"#$%&'()*+,(c) 2022 Andrew LelechenkoBSD3/Andrew Lelechenko  Safe-Inferred$(14Èʺtext-builder-linear Internally à is a mutable buffer. If a client gets hold of a variable of type ¶, they'd be able to pass a mutable buffer to concurrent threads. That's why API below is carefully designed to prevent such possibility: clients always work with linear functions  ¸E # instead and run them on an empty  to extract results. In terms of  /https://hackage.haskell.org/package/linear-base linear-base  is  Õhttps://hackage.haskell.org/package/linear-base/docs/Prelude-Linear.html#t:Consumable Consumable (see ) and  Òhttps://hackage.haskell.org/package/linear-base/docs/Prelude-Linear.html#t:DupableDupable (see  ), but not  Òhttps://hackage.haskell.org/package/linear-base/docs/Prelude-Linear.html#t:MovableMovable.&:set -XOverloadedStrings -XLinearTypes&import Data.Text.Builder.Linear.Buffer7runBuffer (\b -> '!' .<| "foo" <| (b |> "bar" |>. '.')) "!foobar."6Remember: this is a strict builder, so on contrary to Data.Text.Lazy.BuilderÖ for optimal performance you should use strict left folds instead of lazy right ones.à is an unlifted datatype, so you can put it into an unboxed tuple (# ..., ... #), but not into  (..., ...).-text-builder-linearUnwrap Ñ, no-op. Most likely, this is not the function you're looking for and you need  instead.text-builder-linear"Run a linear function on an empty , producing a strict ..Be careful to write runBuffer (b -> ...) instead of runBuffer $ b -> ...Ì, because current implementation of linear types lacks special support for /. Another option is to enable {-# LANGUAGE BlockArguments #-} and write runBuffer b -> ...". Alternatively, you can import  Ïhttps://hackage.haskell.org/package/linear-base/docs/Prelude-Linear.html#v:-36-($) from  /https://hackage.haskell.org/package/linear-base linear-base.0 is similar in spirit to mutable arrays API in  Óhttps://hackage.haskell.org/package/linear-base/docs/Data-Array-Mutable-Linear.htmlData.Array.Mutable.Linear", which provides functions like  Þhttps://hackage.haskell.org/package/linear-base/docs/Data-Array-Mutable-Linear.html#v:fromListfromList ·D [a] ’C (Vector a ¸E  Óhttps://hackage.haskell.org/package/linear-base-0.3.0/docs/Prelude-Linear.html#t:UrUr b) ¸E  Óhttps://hackage.haskell.org/package/linear-base-0.3.0/docs/Prelude-Linear.html#t:UrUr b/. Here the initial buffer is always empty and b is .. Since . is  Òhttps://hackage.haskell.org/package/linear-base/docs/Prelude-Linear.html#t:MovableMovable, . and  Óhttps://hackage.haskell.org/package/linear-base-0.3.0/docs/Prelude-Linear.html#t:UrUr . are equivalent.text-builder-linearSame as ', but returning a UTF-8 encoded strict 0.text-builder-linearÒDuplicate builder. Feel free to process results in parallel threads. Similar to  Òhttps://hackage.haskell.org/package/linear-base/docs/Prelude-Linear.html#t:DupableDupable from  /https://hackage.haskell.org/package/linear-base linear-base.&It is a bit tricky to use because of  Õhttps://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/linear_types.html#limitationscurrent limitations" of linear types with regards to let and where. E. g., one cannot write Àlet (# b1, b2 #) = dupBuffer b in ("foo" <| b1) >< (b2 |> "bar")Instead write:6:set -XOverloadedStrings -XLinearTypes -XUnboxedTuples&import Data.Text.Builder.Linear.BufferÑrunBuffer (\b -> (\(# b1, b2 #) -> ("foo" <| b1) >< (b2 |> "bar")) (dupBuffer b))"foobar"Note the unboxed tuple: 4 is an unlifted datatype, so it cannot be put into  (..., ...).text-builder-linear&Consume buffer linearly, similar to  Õhttps://hackage.haskell.org/package/linear-base/docs/Prelude-Linear.html#t:Consumable Consumable from  /https://hackage.haskell.org/package/linear-base linear-base.text-builder-linear3Erase buffer's content, replacing it with an empty ..text-builder-linearReturn buffer's size in bytes (not in 1Ës). This could be useful to implement a lazy builder atop of a strict one.text-builder-linearReturn buffer's length in 15s (not in bytes). This could be useful to implement  dropEndBuffer and  takeEndBuffer, e. g., Ëimport Data.Unrestricted.Linear dropEndBuffer :: Word -> Buffer %1 -> Buffer dropEndBuffer n buf = ((# buf', len #) -> case move len of Ur len' -> takeBuffer (len' - n) buf') (lengthOfBuffer buf) text-builder-linearSlice  by dropping given number of 1s. text-builder-linearSlice  by taking given number of 1s. text-builder-linear6Low-level routine to append data of unknown size to a . text-builder-linear4Low-level routine to append data of known size to a . text-builder-linear7Low-level routine to prepend data of unknown size to a . text-builder-linear6Low-level routine to append data of unknown size to a .text-builder-linearConcatenate two %s, potentially mutating both of them.You likely need to use % to get hold on two builders at once:6:set -XOverloadedStrings -XLinearTypes -XUnboxedTuples&import Data.Text.Builder.Linear.BufferÑrunBuffer (\b -> (\(# b1, b2 #) -> ("foo" <| b1) >< (b2 |> "bar")) (dupBuffer b))"foobar" text-builder-linear9Upper bound for the number of bytes, written by an actiontext-builder-linearAction, which writes bytes startingÆ from the given offset and returns an actual number of bytes written. text-builder-linear+Exact number of bytes, written by an actiontext-builder-linearAction, which writes bytes starting from the given offset text-builder-linear9Upper bound for the number of bytes, written by an actiontext-builder-linearAction, which writes bytes  finishingÈ before the given offset and returns an actual number of bytes written.text-builder-linearAction, which writes bytes startingÆ from the given offset and returns an actual number of bytes written. text-builder-linear+Exact number of bytes, written by an actiontext-builder-linearAction, which writes bytes starting from the given offset  6(c) 2022 Andrew LelechenkoBSD3/Andrew Lelechenko  Safe-Inferred$(14Èʧtext-builder-linearAppend 1 to a  by mutating it.:set -XLinearTypes#runBuffer (\b -> b |>. 'q' |>. 'w')"qw"In contrast to Î, it's a responsibility of the caller to sanitize surrogate code points with .text-builder-linearPrepend 1 to a  by mutating it.:set -XLinearTypes#runBuffer (\b -> 'q' .<| 'w' .<| b)"qw"In contrast to Î, it's a responsibility of the caller to sanitize surrogate code points with .2text-builder-linear Similar to 3&, but writes _before_ a given offset.66 (c) 2022 Andrew LelechenkoBSD3/Andrew Lelechenko  Safe-Inferred $(14ÈÊtext-builder-linearAppend decimal number.text-builder-linearPrepend decimal number.4text-builder-linear4ceiling (fbs a * logBase 10 2) < ceiling (fbs a * 5  16) < 1 + floor (fbs a * 5  16)66 (c) 2022 Andrew LelechenkoBSD3/Andrew Lelechenko  Safe-Inferred$(14ÈÊîtext-builder-linearAppend double.text-builder-linearPrepend double66 (c) 2022 Andrew LelechenkoBSD3/Andrew Lelechenko  Safe-Inferred$(14ÈÊ!text-builder-linearAppend hexadecimal number.text-builder-linearPrepend hexadecimal number.5text-builder-linearThis assumes n /= 0.66(c) 2022 Andrew LelechenkoBSD3/Andrew Lelechenko  Safe-Inferred$(14ÈÊ'htext-builder-linearAppend . suffix to a  by mutating it. If a suffix is statically known, consider using  for optimal performance.&:set -XOverloadedStrings -XLinearTypes%runBuffer (\b -> b |> "foo" |> "bar")"foobar"text-builder-linearPrepend . prefix to a  by mutating it. If a prefix is statically known, consider using  for optimal performance.&:set -XOverloadedStrings -XLinearTypes%runBuffer (\b -> "foo" <| "bar" <| b)"foobar"text-builder-linear,Append a null-terminated UTF-8 string to a  by mutating it. E. g.,2:set -XOverloadedStrings -XLinearTypes -XMagicHash)runBuffer (\b -> b |># "foo"# |># "bar"#)"foobar"/The literal string must not contain zero bytes \0> and must be a valid UTF-8, these conditions are not checked.ÏNote the inconsistency in naming: unfortunately, GHC parser does not allow for #<|.text-builder-linear-Prepend a null-terminated UTF-8 string to a  by mutating it. E. g.,2:set -XOverloadedStrings -XLinearTypes -XMagicHash)runBuffer (\b -> "foo"# <|# "bar"# <|# b)"foobar"/The literal string must not contain zero bytes \0> and must be a valid UTF-8, these conditions are not checked.text-builder-linearAppend given number of spaces.text-builder-linearPrepend given number of spaces.text-builder-linearThis is just a normal  4, but with a linear arrow and unlifted accumulator.666666(c) 2022 Andrew LelechenkoBSD3/Andrew Lelechenko  Safe-Inferred$(14ÈÊ0k text-builder-linearThin wrapper over  with a handy 6 instance.$:set -XOverloadedStrings -XMagicHash1fromText "foo" <> fromChar '_' <> fromAddr "bar"# "foo_bar"6Remember: this is a strict builder, so on contrary to Data.Text.Lazy.BuilderÖ for optimal performance you should use strict left folds instead of lazy right ones.7Note that (similar to other builders) concatenation of ìs allocates thunks. This is to a certain extent mitigated by aggressive inlining, but it is faster to use  directly.!text-builder-linearRun  computation on an empty , returning strict ..$:set -XOverloadedStrings -XMagicHash>runBuilder (fromText "foo" <> fromChar '_' <> fromAddr "bar"#) "foo_bar"ÞThis function has a polymorphic arrow and thus can be used both in usual and linear contexts."text-builder-linearSame as !', but returning a UTF-8 encoded strict 0.#text-builder-linearCreate , containing a given ..:set -XOverloadedStrings fromText "foo" <> fromText "bar""foobar"$text-builder-linearCreate , containing a given 1.fromChar 'x' <> fromChar 'y'"xy"In contrast to Î, it's a responsibility of the caller to sanitize surrogate code points with .%text-builder-linearCreate :, containing a null-terminated UTF-8 string, specified by 7.:set -XMagicHash"fromAddr "foo"# <> fromAddr "bar"#"foobar"/The literal string must not contain zero bytes \0> and must be a valid UTF-8, these conditions are not checked.&text-builder-linearCreate 7, containing decimal representation of a given integer.$fromChar 'x' <> fromDec (123 :: Int)"x123"'text-builder-linearCreate ;, containing hexadecimal representation of a given integer.:set -XMagicHash+fromAddr "0x"# <> fromHex (0x123def :: Int) "0x123def"(text-builder-linearCreate /, containing decimal representation of a given 8.:set -XMagicHash fromAddr "pi="# <> fromDouble pi"pi=3.141592653589793"  !"#$%&'(  !"#$%&'(9  ! " # $%&'()*+,,-./0123456789:;<=>?@ABCDEF;GH I J=>KCLMCDNÏ/text-builder-linear-0.1.1-ohWPOBk3V92PGyXoAe2F8Data.Text.Builder.Linear.CoreData.Text.Builder.Linear.BufferData.Text.Builder.LinearData.Text.Builder.Linear.CharData.Text.Lazy.Builder singletonData.Text.InternalsafeData.Text.Builder.Linear.DecData.Text.Builder.Linear.DoubleData.Text.Builder.Linear.Hex Data.Listfoldl'Buffer runBuffer runBufferBS dupBuffer consumeBuffer eraseBufferbyteSizeOfBufferlengthOfBuffer dropBuffer takeBuffer appendBounded appendExactprependBounded prependExact><|>..<||>$$<||>%%<||>&&<||><||>#<|#|>……<|foldlIntoBufferBuilder unBuilder runBuilder runBuilderBSfromTextfromCharfromAddrfromDecfromHex fromDouble$fIsStringBuilder$fMonoidBuilder$fSemigroupBuilder $fShowBuilderunBuffer!text-2.0.2-949bMabzxFXAJABVJimBrmTextbaseGHC.Base$bytestring-0.11.3.1Data.ByteString.Internal ByteStringghc-prim GHC.TypesCharunsafePrependCharMData.Text.Internal.Unsafe.Char unsafeWrite maxDecLen lengthAsHex SemigroupGHC.PrimAddr#Double