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-icu-0.8.0.5Haskell98

Data.Text.ICU.BiDi

Implementation of the Unicode Bidirectional Algorithm. See the documentation of the libicu library for additional details.

  • - Note: this module is not thread safe. Do not call the functions on one BiDi object from more than one thread!

  • 2 types
  • 9 values
  • Packagetext-icu-0.8.0.5
  • Exports11
  • LanguageHaskell98
  • LicenceBSD-3-Clause
  • SourceBiDi.hsc
newtypenewtype BiDi
#

BiDi object. Note: this structure is not thread safe. It is not safe to use value of this type simultaneously from multiple threads.

Instances2Eq, Show
  • Eq BiDiDefined in text-icu-0.8.0.5 · Data.Text.ICU.BiDi.Internal
  • Show BiDiDefined in text-icu-0.8.0.5 · Data.Text.ICU.BiDi.Internal

Basic functions

2 declarations
valueopenSized
  1. :: Int32

    is the maximum text or line length that internal memory will be preallocated for. An attempt to associate this object with a longer text will fail, unless this value is 0.

  2. -> Int32

    is the maximum anticipated number of same-level runs that internal memory will be preallocated for. An attempt to access visual runs on an object that was not preallocated for as many runs as the text was actually resolved to will fail, unless this value is 0.

  3. -> IO BiDi
#

Allocate a BiDi structure with preallocated memory for internal structures.

Set data

2 declarations
valuesetPara
  1. :: BiDi
  2. -> Text
  3. -> Int32

    specifies the default level for the text; it is typically 0 (LTR) or 1 (RTL)

  4. -> IO ()
#

Perform the Unicode Bidi algorithm. It is defined in the Unicode Standard Annex #9, version 13, also described in The Unicode Standard, Version 4.0. This function takes a piece of plain text containing one or more paragraphs, with or without externally specified embedding levels from styled text and computes the left-right-directionality of each character.

valuesetLine
  1. :: BiDi

    the parent paragraph object. It must have been set by a successful call to setPara.

  2. -> Int32

    is the line's first index into the text

  3. -> Int32

    is just behind the line's last index into the text (its last index +1).

  4. -> BiDi

    is the object that will now represent a line of the text

  5. -> IO ()
#

Sets a BiDi to contain the reordering information, especially the resolved levels, for all the characters in a line of text

Access the BiDi object

3 declarations
valuegetParagraphByIndex
  1. :: BiDi
  2. -> Int32

    is the number of the paragraph, in the range [0..ubidi_countParagraphs(pBiDi)-1].

  3. -> IO (Int32, Int32)

    index of the first character of the paragraph in the text and limit of the paragraph

#

Get a paragraph, given the index of this paragraph.

Output text

2 declarations
valuewriteReordered :: BiDi -> [WriteOption] -> IO Text
#

Take a BiDi object containing the reordering information for a piece of text (one or more paragraphs) set by setPara or for a line of text set by setLine and write a reordered string to the destination buffer.

datadata WriteOption
#

Constructors

  • DoMirroring

    replace characters with the "mirrored" property in RTL runs by their mirror-image mappings

  • InsertLrmForNumeric

    surround the run with LRMs if necessary; this is part of the approximate "inverse Bidi" algorithm

  • KeepBaseCombining

    keep combining characters after their base characters in RTL runs

  • OutputReverse

    write the output in reverse order

  • RemoveBidiControls

    remove Bidi control characters (this does not affect InsertLrmForNumeric)

Instances1Show

High-level functions

1 declaration