HORIZON HASKELLDocslts/ghc-9.14.x45dd5372026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 45dd537 · 2026-10-11

Moduletext-builder-core-0.1.1.3Haskell2010

TextBuilderCore

  • 1 type
  • 10 values
datadata TextBuilder
#

Composable specification of how to efficiently construct strict Text.

Provides instances of Semigroup and Monoid, which have complexity of O(1).

Constructors

Instances6Eq, Show, IsString, Semigroup, Monoid, Arbitrary

Destructors

2 declarations

Constructors

0 declarations

Text

Character

Safe Unicode codepoint with invalid values replaced by the � char (codepoint 0xfffd), which is the same as what Data.Text.pack does.

Primitives

valueunsafeChars
  1. :: Int

    Maximum size of the provided list of characters.

    Warning: Must be greater than or equal to the length of the list.

  2. -> [Char]
  3. -> TextBuilder
#

Helper for constructing from char producers a bit more efficiently than via (text . fromString).

Example1 expression
unsafeChars 3 "123""123"
Example1 expression
unsafeChars 4 "123""123"
valueunsafeSeptets
  1. :: Int

    Maximum size of the byte array to allocate.

    Must be greater than or equal to the length of the list.

    Warning: If it is smaller, bad things will happen. We'll be writing outside of the allocated array.

  2. -> [Word8]

    List of bytes to write.

    Warning: It is your responsibility to ensure that the bytes are smaller than 128. Otherwise the produced text will have a broken encoding.

    To ensure of optimization kicking in it is advised to construct the list using GHC.List.build.

  3. -> TextBuilder
#

Provides a unified way to deal with the byte array regardless of the version of the text library.

Keep in mind that prior to text-2.0, the array was operating on Word16 values due to the library abstracting over UTF-16. Starting from text-2.0, the array operates on Word8 values and the library abstracts over UTF-8.

This function is useful for building ASCII values.

Example1 expression
unsafeSeptets 3 (fmap (+48) [1, 2, 3])"123"
Example1 expression
unsafeSeptets 4 (fmap (+48) [1, 2, 3])"123"
valueunsafeReverseSeptets
  1. :: Int

    Precise amount of bytes in the list.

    Needs to be precise, because writing happens in reverse order.

    Warning: If it is smaller, bad things will happen. We'll be writing outside of the allocated array.

  2. -> [Word8]

    List of bytes to write in reverse order.

    Warning: It is your responsibility to ensure that the bytes are smaller than 128. Otherwise the produced text will have a broken encoding.

    To ensure of optimization kicking in it is advised to construct the list using GHC.List.build.

  3. -> TextBuilder
#

Same as unsafeSeptets, but writes the bytes in reverse order and requires the size to be precise.

Example1 expression
unsafeReverseSeptets 3 (fmap (+48) [1, 2, 3])"321"