HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduletext-builder-dev-0.3.4.2Haskell2010

TextBuilderDev

  • 1 type
  • 1 class
  • 43 values
datadata TextBuilder
#

Specification of how to efficiently construct strict Text. Provides instances of Semigroup and Monoid, which have complexity of O(1).

Instances16Eq, Show, IsString, Semigroup, Monoid, Arbitrary, …

Accessors

3 declarations

Output IO

Constructors

0 declarations

Builder manipulators

Run the builder and pack the produced text into a new builder.

Useful to have around builders that you reuse, because a forced builder is much faster, since it's virtually a single call memcopy.

Textual

ASCII byte string.

It's your responsibility to ensure that the bytes are in proper range, otherwise the produced text will be broken.

Character

Low-level character

Integers

Decimal

Binary

Hexadecimal

Digits

Real

valuedoublePercent
  1. :: Int

    Amount of decimals after point.

  2. -> Double
  3. -> TextBuilder
#

Double multiplied by 100 with a fixed number of decimal places applied and followed by a percent-sign.

Time

valueutcTimestampInIso8601
  1. :: Int

    Year.

  2. -> Int

    Month.

  3. -> Int

    Day.

  4. -> Int

    Hour.

  5. -> Int

    Minute.

  6. -> Int

    Second.

  7. -> TextBuilder
#

General template for formatting date values according to the ISO8601 standard. The format is the following:

2021-11-24T12:11:02Z

Integrations with various time-libraries can be easily derived from that.

Classes

1 declaration
classclass IsomorphicToTextBuilder a where
#

Evidence that there exists an unambiguous way to convert a type to and from TextBuilder.

Unlike conversion classes from other libs this class is lawful. The law is:

fromTextBuilder . toTextBuilder = id

This class does not provide implicit rendering, such as from integer to its decimal representation. There are multiple ways of representing an integer as text (e.g., hexadecimal, binary). The non-ambiguity is further enforced by the presence of the inverse conversion. In the integer case there is no way to read it from a textual form without a possibility of failing (e.g., when the input string cannot be parsed as an integer).

If you're looking for such conversion classes, this library is not a place for them, since there can be infinite amount of flavours of conversions. They are context-dependent and as such should be defined as part of the domain.

Instances5IsomorphicToTextBuilder