trifecta-1.6.2.1: A modern parser combinator library with convenient diagnostics

Copyright | Edward Kmett 2011-2015
Safe Haskell | None
Language | Haskell2010

Text.Trifecta.Util.Array

Contents

- Creation
- Basic interface
- Folds

Description

Johan Tibell 2011 License : BSD3

Maintainer : ekmett@gmail.com Stability : experimental Portability : unknown

Fast zero based arrays, based on the implementation in the HAMT-branch of unordered-containers

Synopsis

- data Array a
- data MArray s a
- new :: Int -> a -> ST s (MArray s a)
- new_ :: Int -> ST s (MArray s a)
- empty :: Array a
- singleton :: a -> Array a
- length :: Array a -> Int
- lengthM :: MArray s a -> Int
- read :: MArray s a -> Int -> ST s a
- write :: MArray s a -> Int -> a -> ST s ()
- index :: Array a -> Int -> a
- index_ :: Array a -> Int -> ST s a
- indexM_ :: MArray s a -> Int -> ST s a
- update :: Array e -> Int -> e -> Array e
- insert :: Array e -> Int -> e -> Array e
- delete :: Array e -> Int -> Array e
- unsafeFreeze :: MArray s a -> ST s (Array a)
- run :: (forall s. ST s (MArray s e)) -> Array e
- run2 :: (forall s. ST s (MArray s e, a)) -> (Array e, a)
- copy :: Array e -> Int -> MArray s e -> Int -> Int -> ST s ()
- copyM :: MArray s e -> Int -> MArray s e -> Int -> Int -> ST s ()
- foldl' :: (b -> a -> b) -> b -> Array a -> b
- foldr :: (a -> b -> b) -> b -> Array a -> b
- thaw :: Array e -> Int -> Int -> ST s (MArray s e)
- map :: (a -> b) -> Array a -> Array b
- map' :: (a -> b) -> Array a -> Array b
- traverse :: Applicative f => (a -> f b) -> Array a -> f (Array b)
- filter :: (a -> Bool) -> Array a -> Array a

# Documentation

data Array a #

Instances

NFData a => NFData (Array a) # |
Methods rnf :: Array a -> () #

data MArray s a #

# Creation

new :: Int -> a -> ST s (MArray s a) #

Create a new mutable array of specified size, in the specified state thread, with each element containing the specified initial value.

new_ :: Int -> ST s (MArray s a) #

empty :: Array a #

singleton :: a -> Array a #

# Basic interface

length :: Array a -> Int #

lengthM :: MArray s a -> Int #

read :: MArray s a -> Int -> ST s a #

write :: MArray s a -> Int -> a -> ST s () #

index :: Array a -> Int -> a #

index_ :: Array a -> Int -> ST s a #

indexM_ :: MArray s a -> Int -> ST s a #

update :: Array e -> Int -> e -> Array e #

O(n) Update the element at the given position in this array.

insert :: Array e -> Int -> e -> Array e #

O(n) Insert an element at the given position in this array, increasing its size by one.

delete :: Array e -> Int -> Array e #

O(n) Delete an element at the given position in this array, decreasing its size by one.

unsafeFreeze :: MArray s a -> ST s (Array a) #

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

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

copy :: Array e -> Int -> MArray s e -> Int -> Int -> ST s () #

Unsafely copy the elements of an array. Array bounds are not checked.

copyM :: MArray s e -> Int -> MArray s e -> Int -> Int -> ST s () #

Unsafely copy the elements of an array. Array bounds are not checked.

# Folds

foldl' :: (b -> a -> b) -> b -> Array a -> b #

foldr :: (a -> b -> b) -> b -> Array a -> b #

thaw :: Array e -> Int -> Int -> ST s (MArray s e) #

map :: (a -> b) -> Array a -> Array b #

map' :: (a -> b) -> Array a -> Array b #

Strict version of `map`.

traverse :: Applicative f => (a -> f b) -> Array a -> f (Array b) #

filter :: (a -> Bool) -> Array a -> Array a #