Internally Buffer is a mutable buffer. If a client gets hold of a variable of type Buffer, 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 Buffer ⊸ Buffer instead and run them on an empty Buffer to extract results.
In terms of linear-base
Buffer is Consumable
(see consumeBuffer)
and Dupable
(see dupBuffer),
but not Movable.
:set -XOverloadedStrings -XLinearTypesimport Data.Text.Builder.Linear.BufferrunBuffer (\b -> '!' .<| "foo" <| (b |> "bar" |>. '.'))"!foobar."
Remember: 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.
Buffer is an unlifted datatype,
so you can put it into an unboxed tuple (# ..., ... #),
but not into (..., ...).