array-0.5.6.0: Mutable and immutable arrays
Copyright(c) The University of Glasgow 2001
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityprovisional
Portabilityportable
Safe HaskellTrustworthy
LanguageHaskell2010

Data.Array

Description

Basic non-strict arrays.

Note: The Data.Array.IArray module provides a more general interface to immutable arrays: it defines operations with the same names as those defined below, but with more general types, and also defines Array instances of the relevant classes. To use that more general interface, import Data.Array.IArray but not Data.Array.

Synopsis

Immutable non-strict arrays

Haskell provides indexable arrays, which may be thought of as functions whose domains are isomorphic to contiguous subsets of the integers. Functions restricted in this way can be implemented efficiently; in particular, a programmer may reasonably expect rapid access to the components. To ensure the possibility of such an implementation, arrays are treated as data, not as general functions.

Since most array functions involve the class Ix, this module is exported from Data.Array so that modules need not import both Data.Array and Data.Ix.

module Data.Ix

data Array i e #

Instances

Instances details
IArray Array e Source # 
Instance details

Defined in Data.Array.Base

Methods

bounds :: Ix i => Array i e -> (i, i) Source #

numElements :: Ix i => Array i e -> Int Source #

unsafeArray :: Ix i => (i, i) -> [(Int, e)] -> Array i e Source #

unsafeAt :: Ix i => Array i e -> Int -> e Source #

unsafeReplace :: Ix i => Array i e -> [(Int, e)] -> Array i e Source #

unsafeAccum :: Ix i => (e -> e' -> e) -> Array i e -> [(Int, e')] -> Array i e Source #

unsafeAccumArray :: Ix i => (e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> Array i e Source #

Functor (Array i) 
Instance details

Defined in GHC.Internal.Arr

Methods

fmap :: (a -> b) -> Array i a -> Array i b #

(<$) :: a -> Array i b -> Array i a #

Foldable (Array i) 
Instance details

Defined in GHC.Internal.Data.Foldable

Methods

fold :: Monoid m => Array i m -> m #

foldMap :: Monoid m => (a -> m) -> Array i a -> m #

foldMap' :: Monoid m => (a -> m) -> Array i a -> m #

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

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

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

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

foldr1 :: (a -> a -> a) -> Array i a -> a #

foldl1 :: (a -> a -> a) -> Array i a -> a #

toList :: Array i a -> [a] #

null :: Array i a -> Bool #

length :: Array i a -> Int #

elem :: Eq a => a -> Array i a -> Bool #

maximum :: Ord a => Array i a -> a #

minimum :: Ord a => Array i a -> a #

sum :: Num a => Array i a -> a #

product :: Num a => Array i a -> a #

Ix i => Traversable (Array i) 
Instance details

Defined in GHC.Internal.Data.Traversable

Methods

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

sequenceA :: Applicative f => Array i (f a) -> f (Array i a) #

mapM :: Monad m => (a -> m b) -> Array i a -> m (Array i b) #

sequence :: Monad m => Array i (m a) -> m (Array i a) #

(Ix a, Read a, Read b) => Read (Array a b) 
Instance details

Defined in GHC.Internal.Read

(Ix a, Show a, Show b) => Show (Array a b) 
Instance details

Defined in GHC.Internal.Arr

Methods

showsPrec :: Int -> Array a b -> ShowS #

show :: Array a b -> String #

showList :: [Array a b] -> ShowS #

(Ix i, Eq e) => Eq (Array i e) 
Instance details

Defined in GHC.Internal.Arr

Methods

(==) :: Array i e -> Array i e -> Bool #

(/=) :: Array i e -> Array i e -> Bool #

(Ix i, Ord e) => Ord (Array i e) 
Instance details

Defined in GHC.Internal.Arr

Methods

compare :: Array i e -> Array i e -> Ordering #

(<) :: Array i e -> Array i e -> Bool #

(<=) :: Array i e -> Array i e -> Bool #

(>) :: Array i e -> Array i e -> Bool #

(>=) :: Array i e -> Array i e -> Bool #

max :: Array i e -> Array i e -> Array i e #

min :: Array i e -> Array i e -> Array i e #

Array construction

array :: Ix i => (i, i) -> [(i, e)] -> Array i e #

listArray :: Ix i => (i, i) -> [e] -> Array i e #

accumArray :: Ix i => (e -> a -> e) -> e -> (i, i) -> [(i, a)] -> Array i e #

Accessing arrays

(!) :: Ix i => Array i e -> i -> e #

bounds :: Array i e -> (i, i) #

indices :: Ix i => Array i e -> [i] #

elems :: Array i e -> [e] #

assocs :: Ix i => Array i e -> [(i, e)] #

Incremental array updates

(//) :: Ix i => Array i e -> [(i, e)] -> Array i e #

accum :: Ix i => (e -> a -> e) -> Array i e -> [(i, a)] -> Array i e #

Derived arrays

ixmap :: (Ix i, Ix j) => (i, i) -> (i -> j) -> Array j e -> Array i e #