Module Data.Array

Imports

Table of Content

Definitions

data AElem a

Wrapper layer that allows lazy semantics for array elements what is not possible when using Frege's types that correspond to Java primitive types.

Constructors

AE ()   a
data Array i e

The type of immutable non-strict arrays with indices in i and elements in e.

Constructors

Array {lower ∷ i, upper ∷ i, cache ∷ Int, aelems ∷ JArray (AElem e)}

Member Functions

aelemsArray α βJArray (AElem β)

elements of array

assocsIx i ⇒ Array i e → [(i, e)]

The list of associations of an array in index order.

boundsIx i ⇒ Array i e → (i, i)

The bounds with which an array was constructed.

cacheArray α βInt

cached size of array

elemsIx i ⇒ Array i e → [e]

The list of elements of an array in index order.

indicesIx i ⇒ Array i e → [i]

The list of indices of an array in ascending order.

lowerArray α β → α

the index lower bound

numElementsIx i ⇒ Array i eInt

The number of elements in the array.

unsafeAtIx i ⇒ Array i eInt → e

Gets n-th value bypassing indexing

upperArray α β → α

the index upper bound

data STArray s i e

Mutable, non-strict arrays in the ST monad.

Constructors

STArray {lower ∷ i, upper ∷ i, cache ∷ Int, aelems ∷ ArrayOf s (AElem e)}

Member Functions

aelemsSTArray α β γArrayOf α (AElem γ)

elements of array

boundsSTArray s i e → (i, i)

The bounds with which an array was constructed.

cacheSTArray α β γInt

cached size of array

lowerSTArray β α γ → α

the index lower bound

newIx i ⇒ (i, i) → e → ST s (STArray s i e)

Construct STArray with indexed between given bounds and filled with initial value

numElementsSTArray s i eInt

The number of elements in the array.

readIx i ⇒ STArray s i e → i → ST s e

Get value at given index

upperSTArray β α γ → α

the index upper bound

writeIx i ⇒ STArray s i e → i → e → ST s ()

Set value at given index

arrayIx i ⇒ (i, i) → [(i, e)] → Array i e

Construct an array with the specified bounds and containing values for given indices within these bounds.

If some index is present more then once in association list then value will be the last association with that index in the list. If some index is absent in association list then value for that index will (lazily) evaluate to the bottom.

Bounds argument and indices in association list are strictly evaluated in order to validate indices.

listArrayIx i ⇒ (i, i)[e]Array i e

Construct an array from a pair of bounds and a list of values in index order.

!!Ix i ⇒ Array i e → i → e
infixl  9

The value at the given index in an array.

foldrElemsIx i ⇒ (a → b → b) → b → Array i a → b

A right fold over the elements.

foldlElemsIx i ⇒ (b → a → b) → b → Array i a → b

A left fold over the elements.

foldrElems'Ix i ⇒ (a → b → b) → bArray i a → b

A strict right fold over the elements.

foldlElems'Ix i ⇒ (b → a → b) → bArray i a → b

A strict left fold over the elements.

foldl1ElemsIx i ⇒ (a → a → a) → Array i a → a

A left fold over the elements with no starting value.

foldr1ElemsIx i ⇒ (a → a → a) → Array i a → a

A right fold over the elements with no starting value.

accumArrayIx i ⇒ (e → a → e) → e → (i, i) → [(i, a)] → Array i e

The accumArray function deals with repeated indices in the association list using an /accumulating function/ which combines the values of associations with the same index. For example, given a list of values of some index type, hist produces a histogram of the number of occurrences of each index within a specified range:

 hist :: (Ix a, Num b) => (a,a) -> [a] -> Array a b
 hist bnds is = accumArray (+) 0 bnds [(i, 1) | i<-is, Ix.inRange bnds i]

If the accumulating function is strict, then accumArray is strict in the values, as well as the indices, in the association list. Thus, unlike ordinary arrays built with array, accumulated arrays should not in general be recursive.

//Ix i ⇒ Array i e → [(i, e)] → Array i e
infixl  9

Constructs an array identical to the first argument except that it has been updated by the associations in the right argument. For example, if m is a 1-origin, n by n matrix, then

 m//[((i,i), 0) | i <- [1..n]]

is the same matrix, except with the diagonal zeroed.

Repeated indices in the association list are handled as for array.

accumIx i ⇒ (e → a → e) → Array i e → [(i, a)] → Array i e

accum f takes an array and an association list and accumulates pairs from the list into the array with the accumulating function f. Thus accumArray can be defined using accum:

 accumArray f z b = accum f (array b [(i, z) | i <- range b])
amapIx i ⇒ (a → b) → Array i aArray i b

Map elements with function

ixmap ∷ (Ix i, Ix j) ⇒ (i, i) → (i → j) → Array j e → Array i e

ixmap allows for transformations on array indices. It may be thought of as providing function composition on the right with the mapping that the original array embodies.

A similar transformation of array values may be achieved using Functor.fmap from the Array instance of the Functor class.

appPrecInt
appPrec1Int
thawSTArrayIx i ⇒ Array i eST s (STArray s i e)

Create mutable copy of an array

freezeSTArrayIx i ⇒ STArray s i eST s (Array i e)

Create immutable copy of an array

Instances

instance ArrayElement (AElem a)

Member Functions

arrayFromIndexList[(Int, AElem α)]JArray (AElem α)

inherited from ArrayElement.arrayFromIndexList

arrayFromIndexListST[(Int, AElem α)]STMutable β (JArray (AElem α))

inherited from ArrayElement.arrayFromIndexListST

arrayFromList[AElem α]JArray (AElem α)

inherited from ArrayElement.arrayFromList

arrayFromListST[AElem α]STMutable β (JArray (AElem α))

inherited from ArrayElement.arrayFromListST

arrayFromMaybeList[Maybe (AElem α)]JArray (AElem α)

inherited from ArrayElement.arrayFromMaybeList

arrayFromMaybeListST[Maybe (AElem α)]STMutable β (JArray (AElem α))

inherited from ArrayElement.arrayFromMaybeListST

arrayLengthJArray (AElem α)Int
pure native .length

inherited from ArrayElement.arrayLength

elemAtJArray (AElem α)IntAElem α
pure native [i]

inherited from ArrayElement.elemAt

getAtArrayOf β (AElem α)IntST β (Maybe (AElem α))
native [i]

inherited from ArrayElement.getAt

getElemAtArrayOf β (AElem α)IntST β (AElem α)
native [i]

inherited from ArrayElement.getElemAt

itemAtJArray (AElem α)IntMaybe (AElem α)
pure native [i]

inherited from ArrayElement.itemAt

javaClassClass (AElem α)
pure native TAElem.class
listFromArrayJArray (AElem α) → [AElem α]

inherited from ArrayElement.listFromArray

maybeListFromArrayJArray (AElem α) → [Maybe (AElem α)]

inherited from ArrayElement.maybeListFromArray

modifyAt ∷ (AElem α → AElem α) → ArrayOf β (AElem α)IntST β ()

inherited from ArrayElement.modifyAt

modifyElemAt ∷ (AElem α → AElem α) → ArrayOf β (AElem α)IntST β ()

inherited from ArrayElement.modifyElemAt

newArrayIntSTMutable β (JArray (AElem α))
native new[]

inherited from ArrayElement.newArray

setAtArrayOf β (AElem α)IntMaybe (AElem α)ST β ()
native []=

inherited from ArrayElement.setAt

setElemAtArrayOf β (AElem α)IntAElem αST β ()
native []=

inherited from ArrayElement.setElemAt

instance Eq a ⇒ Eq (AElem a)

Member Functions

!=Eq α ⇒ AElem αAElem αBool
infix  7

inherited from Eq.!=

==Eq α ⇒ AElem αAElem αBool
infix  7

Function generated for derived instance.

hashCodeEq α ⇒ AElem αInt

Function generated for derived instance.

instance (Ix i, Eq e) ⇒ Eq (Array i e)

Member Functions

!= ∷ (Ix β, Eq α) ⇒ Array β αArray β αBool
infix  7

inherited from Eq.!=

== ∷ (Ix β, Eq α) ⇒ Array β αArray β αBool
infix  7
hashCode ∷ (Ix β, Eq α) ⇒ Array β αInt
instance Ix i ⇒ Functor (Array i)

Member Functions

fmapIx α ⇒ (β → γ) → Array α βArray α γ
infixl  4
instance (Ix i, Ord e) ⇒ Ord (Array i e)

Member Functions

< ∷ (Ix β, Ord α) ⇒ Array β αArray β αBool
infix  9

inherited from Ord.<

<= ∷ (Ix β, Ord α) ⇒ Array β αArray β αBool
infix  9

inherited from Ord.<=

<=> ∷ (Ix β, Ord α) ⇒ Array β αArray β αOrdering
infix  8
> ∷ (Ix β, Ord α) ⇒ Array β αArray β αBool
infix  9

inherited from Ord.>

>= ∷ (Ix β, Ord α) ⇒ Array β αArray β αBool
infix  9

inherited from Ord.>=

compare ∷ (Ix β, Ord α) ⇒ Array β αArray β αOrdering
infix  8

inherited from Ord.compare

max ∷ (Ix β, Ord α) ⇒ Array β αArray β αArray β α

inherited from Ord.max

min ∷ (Ix β, Ord α) ⇒ Array β αArray β αArray β α

inherited from Ord.min

instance (Ix a, Show a, Show b) ⇒ Show (Array a b)

Member Functions

display ∷ (Ix β, Show β, Show α) ⇒ Array β α → String

inherited from Show.display

show ∷ (Ix β, Show β, Show α) ⇒ Array β α → String
showChars ∷ (Ix β, Show β, Show α) ⇒ Array β α → [Char]

inherited from Show.showChars

showList ∷ (Ix β, Show β, Show α) ⇒ [Array β α]StringString

inherited from Show.showList

showsPrec ∷ (Ix β, Show β, Show α) ⇒ IntArray β α → StringString
showsub ∷ (Ix β, Show β, Show α) ⇒ Array β α → String

inherited from Show.showsub

Functions and Values by Type

Int

appPrec, appPrec1

JArray (AElem α) → IntAElem α

ArrayElement_AElem.elemAt

JArray (AElem α) → IntMaybe (AElem α)

ArrayElement_AElem.itemAt

JArray (AElem α) → [AElem α]

ArrayElement_AElem.listFromArray

JArray (AElem α) → [Maybe (AElem α)]

ArrayElement_AElem.maybeListFromArray

JArray (AElem α) → Int

ArrayElement_AElem.arrayLength

[(Int, AElem α)] → JArray (AElem α)

ArrayElement_AElem.arrayFromIndexList

[AElem α] → JArray (AElem α)

ArrayElement_AElem.arrayFromList

[Maybe (AElem α)] → JArray (AElem α)

ArrayElement_AElem.arrayFromMaybeList

() → a → AElem a

AElem.AE

α → Bool

Array.has$upper, Array.has$cache, Array.has$lower, Array.has$aelems, STArray.has$lower, STArray.has$aelems, STArray.has$cache, STArray.has$upper

Eq α ⇒ AElem α → AElem α → Bool

Eq_AElem.!=, Eq_AElem.==

Eq α ⇒ AElem α → Int

Eq_AElem.hashCode

Class (AElem α)

ArrayElement_AElem.javaClass

(AElem α → AElem α) → ArrayOf β (AElem α) → IntST β ()

ArrayElement_AElem.modifyElemAt, ArrayElement_AElem.modifyAt

Array α β → (IntInt) → Array α β

Array.chg$cache

Array α β → (α→α) → Array α β

Array.chg$lower

Array α β → IntArray α β

Array.upd$cache

Array α β → α → Array α β

Array.upd$upper, Array.upd$lower

Array α β → JArray (AElem β)

Array.aelems

Array α β → Int

Array.cache

Array α β → α

Array.upper, Array.lower

Array β α → (β→β) → Array β α

Array.chg$upper

ArrayOf β (AElem α) → IntAElem α → ST β ()

ArrayElement_AElem.setElemAt

ArrayOf β (AElem α) → IntMaybe (AElem α) → ST β ()

ArrayElement_AElem.setAt

ArrayOf β (AElem α) → IntST β (AElem α)

ArrayElement_AElem.getElemAt

ArrayOf β (AElem α) → IntST β (Maybe (AElem α))

ArrayElement_AElem.getAt

[(Int, AElem α)] → STMutable β (JArray (AElem α))

ArrayElement_AElem.arrayFromIndexListST

[AElem α] → STMutable β (JArray (AElem α))

ArrayElement_AElem.arrayFromListST

[Maybe (AElem α)] → STMutable β (JArray (AElem α))

ArrayElement_AElem.arrayFromMaybeListST

IntSTMutable β (JArray (AElem α))

ArrayElement_AElem.newArray

i → i → IntJArray (AElem e) → Array i e

Array.Array

Ix i ⇒ (a → a → a) → Array i a → a

foldl1Elems, foldr1Elems

Ix i ⇒ Array i e → [(i, e)] → Array i e

//

Ix i ⇒ Array i e → Int → e

Array.unsafeAt

Ix i ⇒ Array i e → i → e

!!

Ix i ⇒ Array i e → (i, i)

Array.bounds

Ix i ⇒ Array i e → [(i, e)]

Array.assocs

Ix i ⇒ Array i e → [e]

Array.elems

Ix i ⇒ Array i e → [i]

Array.indices

Ix i ⇒ Array i e → Int

Array.numElements

Ix i ⇒ (i, i) → [(i, e)] → Array i e

array

Ix i ⇒ (i, i) → [e] → Array i e

listArray

(Ix β, Eq α) ⇒ Array β α → Array β α → Bool

Eq_Array.!=, Eq_Array.==

(Ix β, Eq α) ⇒ Array β α → Int

Eq_Array.hashCode

(Ix β, Ord α) ⇒ Array β α → Array β α → Array β α

Ord_Array.min, Ord_Array.max

(Ix β, Ord α) ⇒ Array β α → Array β α → Bool

Ord_Array.>=, Ord_Array.<, Ord_Array.<=, Ord_Array.>

(Ix β, Ord α) ⇒ Array β α → Array β α → Ordering

Ord_Array.compare, Ord_Array.<=>

(Ix β, Show β, Show α) ⇒ Array β α → String

Show_Array.showsub, Show_Array.display, Show_Array.show

(Ix β, Show β, Show α) ⇒ Array β α → [Char]

Show_Array.showChars

(Ix β, Show β, Show α) ⇒ [Array β α] → StringString

Show_Array.showList

(Ix β, Show β, Show α) ⇒ IntArray β α → StringString

Show_Array.showsPrec

STArray s i e → (i, i)

STArray.bounds

STArray s i e → Int

STArray.numElements

STArray α β γ → (IntInt) → STArray α β γ

STArray.chg$cache

STArray α β γ → (β→β) → STArray α β γ

STArray.chg$lower

STArray α β γ → IntSTArray α β γ

STArray.upd$cache

STArray α β γ → β → STArray α β γ

STArray.upd$lower, STArray.upd$upper

STArray α β γ → ArrayOf α (AElem γ)

STArray.aelems

STArray α β γ → Int

STArray.cache

STArray α γ β → (γ→γ) → STArray α γ β

STArray.chg$upper

STArray β α γ → α

STArray.upper, STArray.lower

Array β α → (JArray (AElem α)→JArray (AElem γ)) → Array β γ

Array.chg$aelems

Array β α → JArray (AElem γ) → Array β γ

Array.upd$aelems

i → i → IntArrayOf s (AElem e) → STArray s i e

STArray.STArray

Ix i ⇒ (a → b → b) → b → Array i a → b

foldrElems, foldrElems'

Ix i ⇒ (a → b) → Array i a → Array i b

amap

Ix i ⇒ (b → a → b) → b → Array i a → b

foldlElems, foldlElems'

Ix i ⇒ (e → a → e) → Array i e → [(i, a)] → Array i e

accum

Ix i ⇒ (e → a → e) → e → (i, i) → [(i, a)] → Array i e

accumArray

Ix i ⇒ STArray s i e → i → e → ST s ()

STArray.write

Ix i ⇒ STArray s i e → i → ST s e

STArray.read

Ix i ⇒ STArray s i e → ST s (Array i e)

freezeSTArray

Ix i ⇒ Array i e → ST s (STArray s i e)

thawSTArray

Ix i ⇒ (i, i) → e → ST s (STArray s i e)

STArray.new

(Ix i, Ix j) ⇒ (i, i) → (i → j) → Array j e → Array i e

ixmap

Ix α ⇒ (β → γ) → Array α β → Array α γ

Functor_Array.fmap

STArray α δ β → (ArrayOf α (AElem β)→ArrayOf γ (AElem ε)) → STArray γ δ ε

STArray.chg$aelems

STArray α δ β → ArrayOf γ (AElem ε) → STArray γ δ ε

STArray.upd$aelems

Valid HTML 4.01 Strict