text-0.11.3.1: An efficient packed Unicode text type.

Portability | portable
Stability | experimental
Maintainer | bos@serpentine.com, rtomharper@googlemail.com, duncan@haskell.org
Safe Haskell | None

Data.Text.Array

Contents

- Types
- Functions

Description

Packed, unboxed, heap-resident arrays. Suitable for performance critical use, both in terms of large data quantities and high speed.

This module is intended to be imported `qualified`, to avoid name clashes with Prelude functions, e.g.

     import qualified Data.Text.Array as A

The names in this module resemble those in the `Array` family of modules, but are shorter due to the assumption of qualifid naming.

Synopsis

- data Array
- data MArray s
- copyM :: MArray s -> Int -> MArray s -> Int -> Int -> ST s ()
- copyI :: MArray s -> Int -> Array -> Int -> Int -> ST s ()
- empty :: Array
- equal :: Array -> Int -> Array -> Int -> Int -> Bool
- run :: (forall s. ST s (MArray s)) -> Array
- run2 :: (forall s. ST s (MArray s, a)) -> (Array, a)
- toList :: Array -> Int -> Int -> [Word16]
- unsafeFreeze :: MArray s -> ST s Array
- unsafeIndex :: Array -> Int -> Word16
- new :: forall s. Int -> ST s (MArray s)
- unsafeWrite :: MArray s -> Int -> Word16 -> ST s ()

# Types

data Array

Immutable array type.

data MArray s

Mutable array type, for use in the ST monad.

# Functions

copyM

Arguments

:: MArray s | Destination
-> Int | Destination offset
-> MArray s | Source
-> Int | Source offset
-> Int | Count
-> ST s () |

Copy some elements of a mutable array.

copyI

Arguments

:: MArray s | Destination
-> Int | Destination offset
-> Array | Source
-> Int | Source offset
-> Int | First offset in destination not to copy (i.e. not length)
-> ST s () |

Copy some elements of an immutable array.

empty :: Array

An empty immutable array.

equal

Arguments

:: Array | First
-> Int | Offset into first
-> Array | Second
-> Int | Offset into second
-> Int | Count
-> Bool |

Compare portions of two arrays for equality. No bounds checking is performed.

run :: (forall s. ST s (MArray s)) -> Array

Run an action in the ST monad and return an immutable array of its result.

run2 :: (forall s. ST s (MArray s, a)) -> (Array, a)

Run an action in the ST monad and return an immutable array of its result paired with whatever else the action returns.

toList :: Array -> Int -> Int -> [Word16]

Convert an immutable array to a list.

unsafeFreeze :: MArray s -> ST s Array

Freeze a mutable array. Do not mutate the `MArray` afterwards!

unsafeIndex :: Array -> Int -> Word16

Unchecked read of an immutable array. May return garbage or crash on an out-of-bounds access.

new :: forall s. Int -> ST s (MArray s)

Create an uninitialized mutable array.

unsafeWrite :: MArray s -> Int -> Word16 -> ST s ()

Unchecked write of a mutable array. May return garbage or crash on an out-of-bounds access.