yi-rope-0.1.0.1: A rope data structure used by Yi

LicenseGPL-2
Maintaineryi-devel@googlegroups.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010
Extensions
  • TypeSynonymInstances
  • FlexibleInstances
  • MultiParamTypeClasses

Yi.OldRope

Contents

Description

This module defines a Rope representation.

While the representation are ByteStrings stored in a finger tree, the indices are actually in number of characters.

This is currently based on utf8-string, but a couple of other packages might be better: text, compact-string.

At the moment none of them has a lazy implementation, which forces us to always export plain Strings. (Utf8-string does not have a proper newtype)

Important: The reason this module exists is to allow benchmarking and behaviour checks against a new implementation. As of today (10th September 2014), Yi imports this module. Notably, this module will be going away and Yi will start using Yi.Rope instead in the near future.

Synopsis

Documentation

Conversions to Rope

Conversions from Rope

List-like functions

length :: Rope -> Int Source

Get the length of the string. (This information cached, so O(1) amortized runtime.)

countNewLines :: Rope -> Int Source

Count the number of newlines in the strings. (This information cached, so O(1) amortized runtime.)

splitAt :: Int -> Rope -> (Rope, Rope) Source

Split the string at the specified position.

splitAtLine :: Int -> Rope -> (Rope, Rope) Source

Split before the specified line. Lines are indexed from 0.

append :: Rope -> Rope -> Rope Source

Append two strings by merging the two finger trees.

IO

Low level functions

splitAtChunkBefore :: Int -> Rope -> (Rope, Rope) Source

Split the rope on a chunk, so that the desired position lies within the first chunk of the second rope.