Data.Attoparsec.Text.Buffer

attoparsec-0.14.4: Fast combinator parsing for bytestrings and text

Copyright | Bryan O'Sullivan 2007-2015
License | BSD3
Maintainer | bos@serpentine.com
Stability | experimental
Portability | GHC
Safe Haskell | None
Language | Haskell2010

Data.Attoparsec.Text.Buffer

Description

An immutable buffer that supports cheap appends.

Synopsis

- data Buffer
- buffer :: Text -> Buffer
- unbuffer :: Buffer -> Text
- unbufferAt :: Int -> Buffer -> Text
- length :: Buffer -> Int
- pappend :: Buffer -> Text -> Buffer
- iter :: Buffer -> Int -> Iter
- iter_ :: Buffer -> Int -> Int
- substring :: Int -> Int -> Buffer -> Text
- lengthCodeUnits :: Text -> Int
- dropCodeUnits :: Int -> Buffer -> Text

# Documentation

data Buffer #

#### Instances

Instances details

Monoid Buffer # |
Instance details Defined in Data.Attoparsec.Text.Buffer Methods mempty :: Buffer # mappend :: Buffer -> Buffer -> Buffer # mconcat :: [Buffer] -> Buffer #
Semigroup Buffer # |
Instance details Defined in Data.Attoparsec.Text.Buffer Methods (<>) :: Buffer -> Buffer -> Buffer # sconcat :: NonEmpty Buffer -> Buffer # stimes :: Integral b => b -> Buffer -> Buffer #
Show Buffer # |
Instance details Defined in Data.Attoparsec.Text.Buffer Methods showsPrec :: Int -> Buffer -> ShowS # show :: Buffer -> String # showList :: [Buffer] -> ShowS #

buffer :: Text -> Buffer #

The initial `Buffer` has no mutable zone, so we can avoid all copies in the (hopefully) common case of no further input being fed to us.

unbuffer :: Buffer -> Text #

unbufferAt :: Int -> Buffer -> Text #

length :: Buffer -> Int #

pappend :: Buffer -> Text -> Buffer #

iter :: Buffer -> Int -> Iter #

O(1) Iterate (unsafely) one step forwards through a UTF-8 array, returning the current character and the delta to add to give the next offset to iterate at.

iter_ :: Buffer -> Int -> Int #

O(1) Iterate one step through a UTF-8 array, returning the delta to add to give the next offset to iterate at.

substring :: Int -> Int -> Buffer -> Text #

lengthCodeUnits :: Text -> Int #

dropCodeUnits :: Int -> Buffer -> Text #