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

Moduletrifecta-2.1.4Haskell2010

Text.Trifecta.Rope

A rope is a data strucure to efficiently store and manipulate long strings. Wikipedia provides a nice overview: https://en.wikipedia.org/wiki/Rope_(data_structure)

  • 2 types
  • 6 values
  • Packagetrifecta-2.1.4
  • Exports8
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceRope.hs
datadata Rope
#

Constructors

Instances10Show, Semigroup, Monoid, HasDelta, HasBytes, Measured, …
datadata Strand
#

Constructors

Instances10Eq, Data, Show, Generic, Hashable, HasDelta, …
valuegrabRest
  1. :: Delta

    Initial offset

  2. -> Rope

    Input

  3. -> r

    Default value if there is no input left

  4. -> (Delta -> ByteString -> r)

    If there is some input left, create an r out of the data from the initial offset until the end

  5. -> r
#

Grab the entire rest of the input Rope, starting at an initial offset, or return a default if we’re already at or beyond the end. Also see grabLine.

Extract a suffix of a certain length from the input:

Example1 expression
grabRest (delta ("Hello " :: ByteString)) (ropeBS "Hello World\nLorem") Nothing (\x y -> Just (x, Lazy.toString y))Just (Columns 6 6,"World\nLorem")

Same deal, but over multiple strands:

Example1 expression
grabRest (delta ("Hel" :: ByteString)) (ropeBS "Hello" <> ropeBS "World") Nothing (\x y -> Just (x, Lazy.toString y))Just (Columns 3 3,"loWorld")

When the offset is too long, fall back to a default:

Example1 expression
grabRest (delta ("OffetTooLong" :: ByteString)) (ropeBS "Hello") Nothing (\x y -> Just (x, Lazy.toString y))Nothing
valuegrabLine
  1. :: Delta

    Initial offset

  2. -> Rope

    Input

  3. -> r

    Default value if there is no input left

  4. -> (Delta -> ByteString -> r)

    If there is some input left, create an r out of the data from the initial offset until the end of the line

  5. -> r
#

Grab the rest of the line at a certain offset in the input Rope, or return a default if there is no newline left in the input. Also see grabRest.

Example1 expression
grabLine (delta ("Hello " :: ByteString)) (ropeBS "Hello" <> ropeBS " World\nLorem") Nothing (\x y -> Just (x, Strict.toString y))Just (Columns 6 6,"World\n")