HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Moduletext-builder-core-0.1.1.3Haskell2010

TextBuilderCore

Contents
  1. Destructors
  2. Constructors
  3. Text
  4. Character
  5. Primitives
Synopsis
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

Constructors

Text

Character

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 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 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"