Returns the element of an immutable array at the specified index, or throws an exception if the index is out of bounds.
ModuleAgda-2.8.0.2Haskell2010
Agda.Utils.IArray
Array utilities.
- 1 type
- 2 classes
- 21 values
- PackageAgda-2.8.0.2
- Exports24
- LanguageHaskell2010
- LicenceMIT
- SourceIArray.hs
Takes an array and a list of pairs and returns an array identical to
the left 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.
As with the array function, if any two associations in the list have
the same index, the value at that index is implementation-dependent.
(In GHC, the last value specified for that index is used.
Other implementations will also do this for unboxed arrays, but Haskell
98 requires that for Array the value at such indices is bottom.)
For most array types, this operation is O(n) where n is the size of the array. However, the diffarray package provides an array type for which this operation has complexity linear in the number of updates.
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])accumArray Constructs an immutable array from a list of associations. Unlike array, the same index is allowed to occur multiple times in the list of associations; an accumulating function is used to combine the values of elements 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, inRange bnds i]Returns a new array derived from the original array by applying a function to each of the elements.
array Constructs an immutable array from a pair of bounds and a list of initial associations.
The bounds are specified as a pair of the lowest and highest bounds in the array respectively. For example, a one-origin vector of length 10 has bounds (1,10), and a one-origin 10 by 10 matrix has bounds ((1,1),(10,10)).
An association is a pair of the form (i,x), which defines the value of
the array at index i to be x. The array is undefined if any index
in the list is out of bounds. If any two associations in the list have
the same index, the value at that index is implementation-dependent.
(In GHC, the last value specified for that index is used.
Other implementations will also do this for unboxed arrays, but Haskell
98 requires that for Array the value at such indices is bottom.)
Because the indices must be checked for these errors, array is
strict in the bounds argument and in the indices of the association
list. Whether array is strict or non-strict in the elements depends
on the array type: Array is a non-strict array type, but
all of the UArray arrays are strict. Thus in a
non-strict array, recurrences such as the following are possible:
a = array (1,100) ((1,1) : [(i, i * a!(i-1)) | i \<- [2..100]])Not every index within the bounds of the array need appear in the association list, but the values associated with indices that do not appear will be undefined.
If, in any dimension, the lower bound is greater than the upper bound, then the array is legal, but empty. Indexing an empty array always gives an array-bounds error, but bounds still yields the bounds with which the array was constructed.
Returns the contents of an array as a list of associations.
Returns a list of all the elements of an array, in the same order as their indices.
Lazy left-associative fold.
Strict accumulating left-associative fold.
Strict accumulating left-associative monadic fold.
Lazy right-associative fold.
Strict accumulating right-associative fold.
Strict accumulating right-associative monadic fold.
forArray_ is traverseArray_ with its arguments flipped.
Constructs an immutable array using a generator function.
Returns a list of all the valid indices in an array.
Returns a new array derived from the original array by applying a function to each of the indices.
Constructs an immutable array from a list of initial elements. The list gives the elements of the array in ascending order beginning with the lowest index.
Map elements to applicative actions, sequence them left-to-right, and discard the results.
Class of immutable array types.
An array type has the form (a i e) where a is the array type
constructor (kind * -> * -> *), i is the index type (a member of
the class Ix), and e is the element type. The IArray class is
parameterised over both a and e, so that instances specialised to
certain element types can be defined.
Instances18IArray, …
IArray UArray Int16Defined in array-0.5.8.0 · Data.Array.BaseIArray UArray Int32Defined in array-0.5.8.0 · Data.Array.BaseIArray UArray Int64Defined in array-0.5.8.0 · Data.Array.BaseIArray UArray Int8Defined in array-0.5.8.0 · Data.Array.BaseIArray UArray BoolDefined in array-0.5.8.0 · Data.Array.BaseIArray UArray CharDefined in array-0.5.8.0 · Data.Array.BaseIArray UArray DoubleDefined in array-0.5.8.0 · Data.Array.BaseIArray UArray FloatDefined in array-0.5.8.0 · Data.Array.BaseIArray UArray IntDefined in array-0.5.8.0 · Data.Array.BaseIArray UArray WordDefined in array-0.5.8.0 · Data.Array.BaseIArray UArray Word16Defined in array-0.5.8.0 · Data.Array.BaseIArray UArray Word32Defined in array-0.5.8.0 · Data.Array.BaseIArray UArray Word64Defined in array-0.5.8.0 · Data.Array.BaseIArray UArray Word8Defined in array-0.5.8.0 · Data.Array.BaseIArray Array eDefined in array-0.5.8.0 · Data.Array.BaseIArray UArray (FunPtr a)Defined in array-0.5.8.0 · Data.Array.BaseIArray UArray (Ptr a)Defined in array-0.5.8.0 · Data.Array.BaseIArray UArray (StablePtr a)Defined in array-0.5.8.0 · Data.Array.Base
The type of immutable non-strict (boxed) arrays
with indices in i and elements in e.
Instances39NFData2, IArray, RegexContext, FoldableWithIndex, FunctorWithIndex, TraversableWithIndex, …
NFData2 ArrayDefined in deepseq-1.5.2.0 · Control.DeepSeqIArray Array eDefined in array-0.5.8.0 · Data.Array.BaseRegexLike a b => RegexContext a b MatchArrayDefined in regex-base-0.94.0.3 · Text.Regex.Base.Context · orphanRegexLike a b => RegexContext a b [MatchArray]Defined in regex-base-0.94.0.3 · Text.Regex.Base.Context · orphanRegexLike a b => RegexContext a b [MatchText b]Defined in regex-base-0.94.0.3 · Text.Regex.Base.Context · orphanRegexLike a b => RegexContext a b (AllMatches (Array Int) MatchArray)Defined in regex-base-0.94.0.3 · Text.Regex.Base.Context · orphanRegexLike a b => RegexContext a b (AllMatches (Array Int) (MatchOffset, MatchLength))Defined in regex-base-0.94.0.3 · Text.Regex.Base.Context · orphanRegexLike a b => RegexContext a b (AllTextMatches (Array Int) (Array Int b))Defined in regex-base-0.94.0.3 · Text.Regex.Base.Context · orphanRegexLike a b => RegexContext a b (AllTextMatches (Array Int) (MatchText b))Defined in regex-base-0.94.0.3 · Text.Regex.Base.Context · orphanRegexLike a b => RegexContext a b (AllTextMatches (Array Int) [b])Defined in regex-base-0.94.0.3 · Text.Regex.Base.Context · orphanRegexLike a b => RegexContext a b (AllTextMatches (Array Int) b)Defined in regex-base-0.94.0.3 · Text.Regex.Base.Context · orphanRegexLike a b => RegexContext a b (AllTextMatches [] (Array Int b))Defined in regex-base-0.94.0.3 · Text.Regex.Base.Context · orphanRegexLike a b => RegexContext a b (AllTextSubmatches (Array Int) (b, (MatchOffset, MatchLength)))Defined in regex-base-0.94.0.3 · Text.Regex.Base.Context · orphanRegexLike a b => RegexContext a b (AllTextSubmatches (Array Int) b)Defined in regex-base-0.94.0.3 · Text.Regex.Base.Context · orphanRegexLike a b => RegexContext a b (b, MatchText b, b)Defined in regex-base-0.94.0.3 · Text.Regex.Base.Context · orphanIx i => FoldableWithIndex i (Array i)Defined in indexed-traversable-0.1.5 · WithIndexIx i => FunctorWithIndex i (Array i)Defined in indexed-traversable-0.1.5 · WithIndexIx i => TraversableWithIndex i (Array i)Defined in indexed-traversable-0.1.5 · WithIndexFunctor (Array i)Defined in ghc-internal-10.0.0 · GHC.Internal.ArrFoldable (Array i)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.FoldableIx i => Traversable (Array i)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.TraversableNFData a => NFData1 (Array a)Defined in deepseq-1.5.2.0 · Control.DeepSeqInvariant (Array i)Defined in invariant-0.6.5 · Data.Functor.Invariantfrom the
arraypackage(Integral i, Ix i) => IsList (Array i e)Defined in ListLike-4.7.8.4 · Data.ListLike.Instances · orphan(Ix i, Eq e) => Eq (Array i e)Defined in ghc-internal-10.0.0 · GHC.Internal.Arr(Data a, Data b, Ix a) => Data (Array a b)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Data(Ix i, Ord e) => Ord (Array i e)Defined in ghc-internal-10.0.0 · GHC.Internal.Arr(Ix a, Read a, Read b) => Read (Array a b)Defined in ghc-internal-10.0.0 · GHC.Internal.Read(Ix a, Show a, Show b) => Show (Array a b)Defined in ghc-internal-10.0.0 · GHC.Internal.Arr(Integral i, Ix i) => IsString (Array i Char)Defined in ListLike-4.7.8.4 · Data.ListLike.Instances · orphan(Integral i, Ix i) => Semigroup (Array i e)Defined in ListLike-4.7.8.4 · Data.ListLike.Instances · orphan(Integral i, Ix i) => Monoid (Array i e)Defined in ListLike-4.7.8.4 · Data.ListLike.Instances · orphan(NFData a, NFData b) => NFData (Array a b)Defined in deepseq-1.5.2.0 · Control.DeepSeq(Binary i, Ix i, Binary e) => Binary (Array i e)Defined in binary-0.8.9.3 · Data.Binary.Class(Integral i, Ix i) => StringLike (Array i Char)Defined in ListLike-4.7.8.4 · Data.ListLike.Instances · orphan(Integral i, Ix i) => ListLike (Array i e) eDefined in ListLike-4.7.8.4 · Data.ListLike.Instances · orphanIx i => FoldableLL (Array i e) eDefined in ListLike-4.7.8.4 · Data.ListLike.Instances · orphan(Integral i, Ix i) => ListLikeIO (Array i Char) CharDefined in ListLike-4.7.8.4 · Data.ListLike.Instances · orphantype Item (Array i e) = eDefined in ListLike-4.7.8.4 · Data.ListLike.Instances · orphan
The Ix class is used to map a contiguous subrange of values in a type onto integers. It is used primarily for array indexing (see the array package).
The first argument (l,u) of each of these operations is a pair
specifying the lower and upper bounds of a contiguous subrange of values.
An implementation is entitled to assume the following laws about these operations:
Methods
range :: (a, a) -> [a]The list of values in the subrange defined by a bounding pair.
index :: (a, a) -> a -> IntThe position of a subscript in the subrange.
inRange :: (a, a) -> a -> BoolReturns True the given subscript lies in the range defined the bounding pair.
rangeSize :: (a, a) -> IntThe size of the subrange defined by a bounding pair.
Instances107Ix, …
Ix AllowedReductionDefined in Agda-2.8.0.2 · Agda.TypeChecking.Monad.BaseIx FunctionFlagDefined in Agda-2.8.0.2 · Agda.TypeChecking.Monad.BaseIx BlinkSpeedDefined in ansi-terminal-types-1.1.3 · System.Console.ANSI.TypesIx ColorDefined in ansi-terminal-types-1.1.3 · System.Console.ANSI.TypesIx ColorIntensityDefined in ansi-terminal-types-1.1.3 · System.Console.ANSI.TypesIx ConsoleIntensityDefined in ansi-terminal-types-1.1.3 · System.Console.ANSI.TypesIx ConsoleLayerDefined in ansi-terminal-types-1.1.3 · System.Console.ANSI.TypesIx UnderliningDefined in ansi-terminal-types-1.1.3 · System.Console.ANSI.TypesIx VoidDefined in ghc-internal-10.0.0 · GHC.Internal.IxIx IntegerDefined in ghc-internal-10.0.0 · GHC.Internal.IxIx NaturalDefined in ghc-internal-10.0.0 · GHC.Internal.IxIx CBoolDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CCharDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CIntDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CIntMaxDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CIntPtrDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CLLongDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CLongDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CPtrdiffDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CSCharDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CShortDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CSigAtomicDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CSizeDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CUCharDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CUIntDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CUIntMaxDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CUIntPtrDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CULLongDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CULongDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CUShortDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx CWcharDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.TypesIx IntPtrDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.PtrIx WordPtrDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.PtrIx AssociativityDefined in ghc-internal-10.0.0 · GHC.Internal.GenericsIx DecidedStrictnessDefined in ghc-internal-10.0.0 · GHC.Internal.GenericsIx SourceStrictnessDefined in ghc-internal-10.0.0 · GHC.Internal.GenericsIx SourceUnpackednessDefined in ghc-internal-10.0.0 · GHC.Internal.GenericsIx SeekModeDefined in ghc-internal-10.0.0 · GHC.Internal.IO.DeviceIx IOModeDefined in ghc-internal-10.0.0 · GHC.Internal.IO.IOModeIx Int16Defined in ghc-internal-10.0.0 · GHC.Internal.IntIx Int32Defined in ghc-internal-10.0.0 · GHC.Internal.IntIx Int64Defined in ghc-internal-10.0.0 · GHC.Internal.IntIx Int8Defined in ghc-internal-10.0.0 · GHC.Internal.IntIx CBlkCntDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx CBlkSizeDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx CClockIdDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx CDevDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx CFsBlkCntDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx CFsFilCntDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx CGidDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx CIdDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx CInoDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx CKeyDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx CModeDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx CNfdsDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx CNlinkDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx COffDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx CPidDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx CRLimDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx CSocklenDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx CSsizeDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx CTcflagDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx CUidDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx FdDefined in ghc-internal-10.0.0 · GHC.Internal.System.Posix.TypesIx BoolDefined in ghc-internal-10.0.0 · GHC.Internal.IxIx CharDefined in ghc-internal-10.0.0 · GHC.Internal.IxIx IntDefined in ghc-internal-10.0.0 · GHC.Internal.IxIx OrderingDefined in ghc-internal-10.0.0 · GHC.Internal.IxIx WordDefined in ghc-internal-10.0.0 · GHC.Internal.IxIx GeneralCategoryDefined in ghc-internal-10.0.0 · GHC.Internal.UnicodeIx Word16Defined in ghc-internal-10.0.0 · GHC.Internal.WordIx Word32Defined in ghc-internal-10.0.0 · GHC.Internal.WordIx Word64Defined in ghc-internal-10.0.0 · GHC.Internal.WordIx Word8Defined in ghc-internal-10.0.0 · GHC.Internal.WordIx PeanoDefined in peano-0.1.1.0 · Data.PeanoIx DayDefined in time-1.16.0.1 · Data.Time.Calendar.DaysIx MonthDefined in time-1.16.0.1 · Data.Time.Calendar.MonthIx QuarterDefined in time-1.16.0.1 · Data.Time.Calendar.QuarterIx QuarterOfYearDefined in time-1.16.0.1 · Data.Time.Calendar.QuarterIx DayOfWeekDefined in time-1.16.0.1 · Data.Time.Calendar.WeekIx ()Defined in ghc-internal-10.0.0 · GHC.Internal.IxIx a => Ix (Large a)Defined in QuickCheck-2.19.0.0 · Test.QuickCheck.ModifiersIx a => Ix (NoShrink a)Defined in QuickCheck-2.19.0.0 · Test.QuickCheck.ModifiersIx a => Ix (Small a)Defined in QuickCheck-2.19.0.0 · Test.QuickCheck.ModifiersIx a => Ix (Identity a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Functor.IdentityIx a => Ix (Down a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.OrdIx a => Ix (a)Defined in ghc-internal-10.0.0 · GHC.Internal.IxIx i => Ix (MIx i)Defined in Agda-2.8.0.2 · Agda.Termination.SparseMatrix(Generic a, Ord (Rep a ()), GIx (Rep a)) => Ix (Generically a)Defined in generic-data-1.1.0.2 · Generic.Data.Internal.Generically · orphanIx (Proxy s)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Proxy(Ix a, Ix b) => Ix (Pair a b)Defined in strict-0.5.1 · Data.Strict.Tuple(Ix a, Ix b) => Ix (a, b)Defined in ghc-internal-10.0.0 · GHC.Internal.IxIx a => Ix (Const a b)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Functor.ConstIx b => Ix (Tagged s b)Defined in tagged-0.8.11 · Data.Tagged(Ix a1, Ix a2, Ix a3) => Ix (a1, a2, a3)Defined in ghc-internal-10.0.0 · GHC.Internal.Ix(Ix a1, Ix a2, Ix a3, Ix a4) => Ix (a1, a2, a3, a4)Defined in ghc-internal-10.0.0 · GHC.Internal.Ix(Ix a1, Ix a2, Ix a3, Ix a4, Ix a5) => Ix (a1, a2, a3, a4, a5)Defined in ghc-internal-10.0.0 · GHC.Internal.Ix(Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6) => Ix (a1, a2, a3, a4, a5, a6)Defined in ghc-internal-10.0.0 · GHC.Internal.Ix(Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6, Ix a7) => Ix (a1, a2, a3, a4, a5, a6, a7)Defined in ghc-internal-10.0.0 · GHC.Internal.Ix(Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6, Ix a7, Ix a8) => Ix (a1, a2, a3, a4, a5, a6, a7, a8)Defined in ghc-internal-10.0.0 · GHC.Internal.Ix(Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6, Ix a7, Ix a8, Ix a9) => Ix (a1, a2, a3, a4, a5, a6, a7, a8, a9)Defined in ghc-internal-10.0.0 · GHC.Internal.Ix(Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6, Ix a7, Ix a8, Ix a9, Ix aA) => Ix (a1, a2, a3, a4, a5, a6, a7, a8, a9, aA)Defined in ghc-internal-10.0.0 · GHC.Internal.Ix(Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6, Ix a7, Ix a8, Ix a9, Ix aA, Ix aB) => Ix (a1, a2, a3, a4, a5, a6, a7, a8, a9, aA, aB)Defined in ghc-internal-10.0.0 · GHC.Internal.Ix(Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6, Ix a7, Ix a8, Ix a9, Ix aA, Ix aB, Ix aC) => Ix (a1, a2, a3, a4, a5, a6, a7, a8, a9, aA, aB, aC)Defined in ghc-internal-10.0.0 · GHC.Internal.Ix(Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6, Ix a7, Ix a8, Ix a9, Ix aA, Ix aB, Ix aC, Ix aD) => Ix (a1, a2, a3, a4, a5, a6, a7, a8, a9, aA, aB, aC, aD)Defined in ghc-internal-10.0.0 · GHC.Internal.Ix(Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6, Ix a7, Ix a8, Ix a9, Ix aA, Ix aB, Ix aC, Ix aD, Ix aE) => Ix (a1, a2, a3, a4, a5, a6, a7, a8, a9, aA, aB, aC, aD, aE)Defined in ghc-internal-10.0.0 · GHC.Internal.Ix(Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6, Ix a7, Ix a8, Ix a9, Ix aA, Ix aB, Ix aC, Ix aD, Ix aE, Ix aF) => Ix (a1, a2, a3, a4, a5, a6, a7, a8, a9, aA, aB, aC, aD, aE, aF)Defined in ghc-internal-10.0.0 · GHC.Internal.Ix