Movatterモバイル変換
[0]ホーム
{-# LANGUAGE BangPatterns , CPP , RankNTypes , MagicHash , UnboxedTuples , MultiParamTypeClasses , FlexibleInstances , FlexibleContexts , UnliftedFFITypes , RoleAnnotations #-}{-# OPTIONS_HADDOCK hide #-}------------------------------------------------------------------------------- |-- Module : Data.Array.Base-- Copyright : (c) The University of Glasgow 2001-- License : BSD-style (see the file libraries/base/LICENSE)---- Maintainer : libraries@haskell.org-- Stability : experimental-- Portability : non-portable (MPTCs, uses Control.Monad.ST)---- Basis for IArray and MArray. Not intended for external consumption;-- use IArray or MArray instead.-------------------------------------------------------------------------------moduleData.Array.BasewhereimportControl.Monad.ST.Lazy(strictToLazyST)importqualifiedControl.Monad.ST.LazyasLazy(ST)importData.Ix(Ix,range,index,rangeSize)importForeign.C.TypesimportForeign.StablePtrimportData.CharimportGHC.Arr(STArray)importqualifiedGHC.ArrasArrimportqualifiedGHC.ArrasArrSTimportGHC.ST(ST(..),runST)importGHC.Base(IO(..),divInt#)importGHC.ExtsimportGHC.Ptr(nullPtr,nullFunPtr)importGHC.Show(appPrec)importGHC.Stable(StablePtr(..))importGHC.Read(expectP,parens,Read(..))importGHC.Int(Int8(..),Int16(..),Int32(..),Int64(..))importGHC.Word(Word8(..),Word16(..),Word32(..),Word64(..))importGHC.IO(stToIO)importGHC.IOArray(IOArray(..),newIOArray,unsafeReadIOArray,unsafeWriteIOArray)importText.Read.Lex(Lexeme(Ident))importText.ParserCombinators.ReadPrec(prec,ReadPrec,step)#include "MachDeps.h"------------------------------------------------------------------------------- Class of immutable arrays{- | Class of immutable array types.An array type has the form @(a i e)@ where @a@ is the array typeconstructor (kind @* -> * -> *@), @i@ is the index type (a member ofthe class 'Ix'), and @e@ is the element type. The @IArray@ class isparameterised over both @a@ and @e@, so that instances specialised tocertain element types can be defined.-}classIArrayaewhere-- | Extracts the bounds of an immutable arraybounds::Ixi=>aie->(i,i)numElements::Ixi=>aie->IntunsafeArray::Ixi=>(i,i)->[(Int,e)]->aieunsafeAt::Ixi=>aie->Int->eunsafeReplace::Ixi=>aie->[(Int,e)]->aieunsafeAccum::Ixi=>(e->e'->e)->aie->[(Int,e')]->aieunsafeAccumArray::Ixi=>(e->e'->e)->e->(i,i)->[(Int,e')]->aieunsafeReplacearr :: a i earries :: [(Int, e)]ies=(forall s. ST s (a i e)) -> a i eforall a. (forall s. ST s a) -> arunST(a i e -> [(Int, e)] -> ST s (STArray s i e)forall (a :: * -> * -> *) e i s.(IArray a e, Ix i) =>a i e -> [(Int, e)] -> ST s (STArray s i e)unsafeReplaceSTa i earr[(Int, e)]iesST s (STArray s i e)-> (STArray s i e -> ST s (a i e)) -> ST s (a i e)forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b>>=STArray s i e -> ST s (a i e)forall i (a :: * -> * -> *) e (m :: * -> *) (b :: * -> * -> *).(Ix i, MArray a e m, IArray b e) =>a i e -> m (b i e)unsafeFreeze)unsafeAccumf :: e -> e' -> efarr :: a i earries :: [(Int, e')]ies=(forall s. ST s (a i e)) -> a i eforall a. (forall s. ST s a) -> arunST((e -> e' -> e) -> a i e -> [(Int, e')] -> ST s (STArray s i e)forall (a :: * -> * -> *) e i e' s.(IArray a e, Ix i) =>(e -> e' -> e) -> a i e -> [(Int, e')] -> ST s (STArray s i e)unsafeAccumSTe -> e' -> efa i earr[(Int, e')]iesST s (STArray s i e)-> (STArray s i e -> ST s (a i e)) -> ST s (a i e)forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b>>=STArray s i e -> ST s (a i e)forall i (a :: * -> * -> *) e (m :: * -> *) (b :: * -> * -> *).(Ix i, MArray a e m, IArray b e) =>a i e -> m (b i e)unsafeFreeze)unsafeAccumArrayf :: e -> e' -> efe :: eelu :: (i, i)luies :: [(Int, e')]ies=(forall s. ST s (a i e)) -> a i eforall a. (forall s. ST s a) -> arunST((e -> e' -> e)-> e -> (i, i) -> [(Int, e')] -> ST s (STArray s i e)forall i e e' s.Ix i =>(e -> e' -> e)-> e -> (i, i) -> [(Int, e')] -> ST s (STArray s i e)unsafeAccumArraySTe -> e' -> efee(i, i)lu[(Int, e')]iesST s (STArray s i e)-> (STArray s i e -> ST s (a i e)) -> ST s (a i e)forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b>>=STArray s i e -> ST s (a i e)forall i (a :: * -> * -> *) e (m :: * -> *) (b :: * -> * -> *).(Ix i, MArray a e m, IArray b e) =>a i e -> m (b i e)unsafeFreeze){-# INLINEsafeRangeSize#-}safeRangeSize::Ixi=>(i,i)->IntsafeRangeSize :: (i, i) -> IntsafeRangeSize(l :: il,u :: iu)=letr :: Intr=(i, i) -> Intforall a. Ix a => (a, a) -> IntrangeSize(il,iu)inifIntrInt -> Int -> Boolforall a. Ord a => a -> a -> Bool<0then[Char] -> Intforall a. HasCallStack => [Char] -> aerror"Negative range size"elseIntr{-# INLINEsafeIndex#-}safeIndex::Ixi=>(i,i)->Int->i->IntsafeIndex :: (i, i) -> Int -> i -> IntsafeIndex(l :: il,u :: iu)n :: Intni :: ii=leti' :: Inti'=(i, i) -> i -> Intforall a. Ix a => (a, a) -> a -> Intindex(il,iu)iiinif(0Int -> Int -> Boolforall a. Ord a => a -> a -> Bool<=Inti')Bool -> Bool -> Bool&&(Inti'Int -> Int -> Boolforall a. Ord a => a -> a -> Bool<Intn)thenInti'else[Char] -> Intforall a. HasCallStack => [Char] -> aerror("Error in array index; "[Char] -> [Char] -> [Char]forall a. [a] -> [a] -> [a]++Int -> [Char]forall a. Show a => a -> [Char]showInti'[Char] -> [Char] -> [Char]forall a. [a] -> [a] -> [a]++" not in range [0.."[Char] -> [Char] -> [Char]forall a. [a] -> [a] -> [a]++Int -> [Char]forall a. Show a => a -> [Char]showIntn[Char] -> [Char] -> [Char]forall a. [a] -> [a] -> [a]++")"){-# INLINEunsafeReplaceST#-}unsafeReplaceST::(IArrayae,Ixi)=>aie->[(Int,e)]->STs(STArraysie)unsafeReplaceST :: a i e -> [(Int, e)] -> ST s (STArray s i e)unsafeReplaceSTarr :: a i earries :: [(Int, e)]ies=doSTArray s i emarr<-a i e -> ST s (STArray s i e)forall i (a :: * -> * -> *) e (b :: * -> * -> *) (m :: * -> *).(Ix i, IArray a e, MArray b e m) =>a i e -> m (b i e)thawa i earr[ST s ()] -> ST s ()forall (t :: * -> *) (m :: * -> *) a.(Foldable t, Monad m) =>t (m a) -> m ()sequence_[STArray s i e -> Int -> e -> ST s ()forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> e -> m ()unsafeWriteSTArray s i emarrIntiee|(i :: Inti,e :: ee)<-[(Int, e)]ies]STArray s i e -> ST s (STArray s i e)forall (m :: * -> *) a. Monad m => a -> m areturnSTArray s i emarr{-# INLINEunsafeAccumST#-}unsafeAccumST::(IArrayae,Ixi)=>(e->e'->e)->aie->[(Int,e')]->STs(STArraysie)unsafeAccumST :: (e -> e' -> e) -> a i e -> [(Int, e')] -> ST s (STArray s i e)unsafeAccumSTf :: e -> e' -> efarr :: a i earries :: [(Int, e')]ies=doSTArray s i emarr<-a i e -> ST s (STArray s i e)forall i (a :: * -> * -> *) e (b :: * -> * -> *) (m :: * -> *).(Ix i, IArray a e, MArray b e m) =>a i e -> m (b i e)thawa i earr[ST s ()] -> ST s ()forall (t :: * -> *) (m :: * -> *) a.(Foldable t, Monad m) =>t (m a) -> m ()sequence_[doeold<-STArray s i e -> Int -> ST s eforall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> m eunsafeReadSTArray s i emarrIntiSTArray s i e -> Int -> e -> ST s ()forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> e -> m ()unsafeWriteSTArray s i emarrInti(e -> e' -> efeolde'new)|(i :: Inti,new :: e'new)<-[(Int, e')]ies]STArray s i e -> ST s (STArray s i e)forall (m :: * -> *) a. Monad m => a -> m areturnSTArray s i emarr{-# INLINEunsafeAccumArrayST#-}unsafeAccumArrayST::Ixi=>(e->e'->e)->e->(i,i)->[(Int,e')]->STs(STArraysie)unsafeAccumArrayST :: (e -> e' -> e)-> e -> (i, i) -> [(Int, e')] -> ST s (STArray s i e)unsafeAccumArraySTf :: e -> e' -> efe :: ee(l :: il,u :: iu)ies :: [(Int, e')]ies=doSTArray s i emarr<-(i, i) -> e -> ST s (STArray s i e)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(il,iu)ee[ST s ()] -> ST s ()forall (t :: * -> *) (m :: * -> *) a.(Foldable t, Monad m) =>t (m a) -> m ()sequence_[doeold<-STArray s i e -> Int -> ST s eforall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> m eunsafeReadSTArray s i emarrIntiSTArray s i e -> Int -> e -> ST s ()forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> e -> m ()unsafeWriteSTArray s i emarrInti(e -> e' -> efeolde'new)|(i :: Inti,new :: e'new)<-[(Int, e')]ies]STArray s i e -> ST s (STArray s i e)forall (m :: * -> *) a. Monad m => a -> m areturnSTArray s i emarr{-# INLINEarray#-}{-| Constructs an immutable array from a pair of bounds and a list ofinitial associations.The bounds are specified as a pair of the lowest and highest bounds inthe array respectively. For example, a one-origin vector of length 10has 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 ofthe array at index @i@ to be @x@. The array is undefined if any indexin the list is out of bounds. If any two associations in the list havethe 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 Haskell98 requires that for 'Array' the value at such indices is bottom.)Because the indices must be checked for these errors, 'array' isstrict in the bounds argument and in the indices of the associationlist. Whether @array@ is strict or non-strict in the elements dependson the array type: 'Data.Array.Array' is a non-strict array type, butall of the 'Data.Array.Unboxed.UArray' arrays are strict. Thus in anon-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 theassociation list, but the values associated with indices that do notappear 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 alwaysgives an array-bounds error, but 'bounds' still yields the bounds withwhich the array was constructed.-}array::(IArrayae,Ixi)=>(i,i)-- ^ bounds of the array: (lowest,highest)->[(i,e)]-- ^ list of associations->aiearray :: (i, i) -> [(i, e)] -> a i earray(l :: il,u :: iu)ies :: [(i, e)]ies=letn :: Intn=(i, i) -> Intforall a. Ix a => (a, a) -> IntsafeRangeSize(il,iu)in(i, i) -> [(Int, e)] -> a i eforall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>(i, i) -> [(Int, e)] -> a i eunsafeArray(il,iu)[((i, i) -> Int -> i -> Intforall i. Ix i => (i, i) -> Int -> i -> IntsafeIndex(il,iu)Intnii,ee)|(i :: ii,e :: ee)<-[(i, e)]ies]-- Since unsafeFreeze is not guaranteed to be only a cast, we will-- use unsafeArray and zip instead of a specialized loop to implement-- listArray, unlike Array.listArray, even though it generates some-- unnecessary heap allocation. Will use the loop only when we have-- fast unsafeFreeze, namely for Array and UArray (well, they cover-- almost all cases).{-# INLINE[1]listArray#-}-- | 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.listArray::(IArrayae,Ixi)=>(i,i)->[e]->aielistArray :: (i, i) -> [e] -> a i elistArray(l :: il,u :: iu)es :: [e]es=letn :: Intn=(i, i) -> Intforall a. Ix a => (a, a) -> IntsafeRangeSize(il,iu)in(i, i) -> [(Int, e)] -> a i eforall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>(i, i) -> [(Int, e)] -> a i eunsafeArray(il,iu)([Int] -> [e] -> [(Int, e)]forall a b. [a] -> [b] -> [(a, b)]zip[0..IntnInt -> Int -> Intforall a. Num a => a -> a -> a-1][e]es){-# INLINElistArrayST#-}listArrayST::Ixi=>(i,i)->[e]->STs(STArraysie)listArrayST :: (i, i) -> [e] -> ST s (STArray s i e)listArrayST(l :: il,u :: iu)es :: [e]es=doSTArray s i emarr<-(i, i) -> ST s (STArray s i e)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> m (a i e)newArray_(il,iu)letn :: Intn=(i, i) -> Intforall a. Ix a => (a, a) -> IntsafeRangeSize(il,iu)letfillFromList :: Int -> [e] -> m ()fillFromListi :: Intixs :: [e]xs|IntiInt -> Int -> Boolforall a. Eq a => a -> a -> Bool==Intn=() -> m ()forall (m :: * -> *) a. Monad m => a -> m areturn()|Boolotherwise=case[e]xsof[]->() -> m ()forall (m :: * -> *) a. Monad m => a -> m areturn()y :: ey:ys :: [e]ys->STArray s i e -> Int -> e -> m ()forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> e -> m ()unsafeWriteSTArray s i emarrIntieym () -> m () -> m ()forall (m :: * -> *) a b. Monad m => m a -> m b -> m b>>Int -> [e] -> m ()fillFromList(IntiInt -> Int -> Intforall a. Num a => a -> a -> a+1)[e]ysInt -> [e] -> ST s ()forall (m :: * -> *). MArray (STArray s) e m => Int -> [e] -> m ()fillFromList0[e]esSTArray s i e -> ST s (STArray s i e)forall (m :: * -> *) a. Monad m => a -> m areturnSTArray s i emarr{-# RULES"listArray/Array"listArray=\lues->runST(listArraySTlues>>=ArrST.unsafeFreezeSTArray)#-}{-# INLINElistUArrayST#-}listUArrayST::(MArray(STUArrays)e(STs),Ixi)=>(i,i)->[e]->STs(STUArraysie)listUArrayST :: (i, i) -> [e] -> ST s (STUArray s i e)listUArrayST(l :: il,u :: iu)es :: [e]es=doSTUArray s i emarr<-(i, i) -> ST s (STUArray s i e)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> m (a i e)newArray_(il,iu)letn :: Intn=(i, i) -> Intforall a. Ix a => (a, a) -> IntsafeRangeSize(il,iu)letfillFromList :: Int -> [e] -> m ()fillFromListi :: Intixs :: [e]xs|IntiInt -> Int -> Boolforall a. Eq a => a -> a -> Bool==Intn=() -> m ()forall (m :: * -> *) a. Monad m => a -> m areturn()|Boolotherwise=case[e]xsof[]->() -> m ()forall (m :: * -> *) a. Monad m => a -> m areturn()y :: ey:ys :: [e]ys->STUArray s i e -> Int -> e -> m ()forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> e -> m ()unsafeWriteSTUArray s i emarrIntieym () -> m () -> m ()forall (m :: * -> *) a b. Monad m => m a -> m b -> m b>>Int -> [e] -> m ()fillFromList(IntiInt -> Int -> Intforall a. Num a => a -> a -> a+1)[e]ysInt -> [e] -> ST s ()forall (m :: * -> *). MArray (STUArray s) e m => Int -> [e] -> m ()fillFromList0[e]esSTUArray s i e -> ST s (STUArray s i e)forall (m :: * -> *) a. Monad m => a -> m areturnSTUArray s i emarr-- I don't know how to write a single rule for listUArrayST, because-- the type looks like constrained over 's', which runST doesn't-- like. In fact all MArray (STUArray s) instances are polymorphic-- wrt. 's', but runST can't know that.---- More precisely, we'd like to write this:-- listUArray :: (forall s. MArray (STUArray s) e (ST s), Ix i)-- => (i,i) -> [e] -> UArray i e-- listUArray lu = runST (listUArrayST lu es >>= unsafeFreezeSTUArray)-- {-# RULES listArray = listUArray-- Then we could call listUArray at any type 'e' that had a suitable-- MArray instance. But sadly we can't, because we don't have quantified-- constraints. Hence the mass of rules below.-- I would like also to write a rule for listUArrayST (or listArray or-- whatever) applied to unpackCString#. Unfortunately unpackCString#-- calls seem to be floated out, then floated back into the middle-- of listUArrayST, so I was not able to do this.typeListUArraye=foralli.Ixi=>(i,i)->[e]->UArrayie{-# RULES"listArray/UArray/Bool"listArray=(\lues->runST(listUArraySTlues>>=unsafeFreezeSTUArray))::ListUArrayBool"listArray/UArray/Char"listArray=(\lues->runST(listUArraySTlues>>=unsafeFreezeSTUArray))::ListUArrayChar"listArray/UArray/Int"listArray=(\lues->runST(listUArraySTlues>>=unsafeFreezeSTUArray))::ListUArrayInt"listArray/UArray/Word"listArray=(\lues->runST(listUArraySTlues>>=unsafeFreezeSTUArray))::ListUArrayWord"listArray/UArray/Ptr"listArray=(\lues->runST(listUArraySTlues>>=unsafeFreezeSTUArray))::ListUArray(Ptra)"listArray/UArray/FunPtr"listArray=(\lues->runST(listUArraySTlues>>=unsafeFreezeSTUArray))::ListUArray(FunPtra)"listArray/UArray/Float"listArray=(\lues->runST(listUArraySTlues>>=unsafeFreezeSTUArray))::ListUArrayFloat"listArray/UArray/Double"listArray=(\lues->runST(listUArraySTlues>>=unsafeFreezeSTUArray))::ListUArrayDouble"listArray/UArray/StablePtr"listArray=(\lues->runST(listUArraySTlues>>=unsafeFreezeSTUArray))::ListUArray(StablePtra)"listArray/UArray/Int8"listArray=(\lues->runST(listUArraySTlues>>=unsafeFreezeSTUArray))::ListUArrayInt8"listArray/UArray/Int16"listArray=(\lues->runST(listUArraySTlues>>=unsafeFreezeSTUArray))::ListUArrayInt16"listArray/UArray/Int32"listArray=(\lues->runST(listUArraySTlues>>=unsafeFreezeSTUArray))::ListUArrayInt32"listArray/UArray/Int64"listArray=(\lues->runST(listUArraySTlues>>=unsafeFreezeSTUArray))::ListUArrayInt64"listArray/UArray/Word8"listArray=(\lues->runST(listUArraySTlues>>=unsafeFreezeSTUArray))::ListUArrayWord8"listArray/UArray/Word16"listArray=(\lues->runST(listUArraySTlues>>=unsafeFreezeSTUArray))::ListUArrayWord16"listArray/UArray/Word32"listArray=(\lues->runST(listUArraySTlues>>=unsafeFreezeSTUArray))::ListUArrayWord32"listArray/UArray/Word64"listArray=(\lues->runST(listUArraySTlues>>=unsafeFreezeSTUArray))::ListUArrayWord64#-}{-# INLINE(!)#-}-- | Returns the element of an immutable array at the specified index.(!)::(IArrayae,Ixi)=>aie->i->e(!)arr :: a i earri :: ii=casea i e -> (i, i)forall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> (i, i)boundsa i earrof(l :: il,u :: iu)->a i e -> Int -> eforall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> Int -> eunsafeAta i earr(Int -> e) -> Int -> eforall a b. (a -> b) -> a -> b$(i, i) -> Int -> i -> Intforall i. Ix i => (i, i) -> Int -> i -> IntsafeIndex(il,iu)(a i e -> Intforall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> IntnumElementsa i earr)ii{-# INLINEindices#-}-- | Returns a list of all the valid indices in an array.indices::(IArrayae,Ixi)=>aie->[i]indices :: a i e -> [i]indicesarr :: a i earr=casea i e -> (i, i)forall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> (i, i)boundsa i earrof(l :: il,u :: iu)->(i, i) -> [i]forall a. Ix a => (a, a) -> [a]range(il,iu){-# INLINEelems#-}-- | Returns a list of all the elements of an array, in the same order-- as their indices.elems::(IArrayae,Ixi)=>aie->[e]elems :: a i e -> [e]elemsarr :: a i earr=[a i e -> Int -> eforall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> Int -> eunsafeAta i earrInti|Inti<-[0..a i e -> Intforall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> IntnumElementsa i earrInt -> Int -> Intforall a. Num a => a -> a -> a-1]]{-# INLINEassocs#-}-- | Returns the contents of an array as a list of associations.assocs::(IArrayae,Ixi)=>aie->[(i,e)]assocs :: a i e -> [(i, e)]assocsarr :: a i earr=casea i e -> (i, i)forall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> (i, i)boundsa i earrof(l :: il,u :: iu)->[(ii,a i earra i e -> i -> eforall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> i -> e!ii)|ii<-(i, i) -> [i]forall a. Ix a => (a, a) -> [a]range(il,iu)]{-# INLINEaccumArray#-}{-|Constructs an immutable array from a list of associations. Unlike'array', the same index is allowed to occur multiple times in the listof associations; an /accumulating function/ is used to combine thevalues of elements with the same index.For example, given a list of values of some index type, hist producesa histogram of the number of occurrences of each index within aspecified 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]-}accumArray::(IArrayae,Ixi)=>(e->e'->e)-- ^ An accumulating function->e-- ^ A default element->(i,i)-- ^ The bounds of the array->[(i,e')]-- ^ List of associations->aie-- ^ Returns: the arrayaccumArray :: (e -> e' -> e) -> e -> (i, i) -> [(i, e')] -> a i eaccumArrayf :: e -> e' -> efinitialValue :: einitialValue(l :: il,u :: iu)ies :: [(i, e')]ies=letn :: Intn=(i, i) -> Intforall a. Ix a => (a, a) -> IntsafeRangeSize(il,iu)in(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> a i eforall (a :: * -> * -> *) e i e'.(IArray a e, Ix i) =>(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> a i eunsafeAccumArraye -> e' -> efeinitialValue(il,iu)[((i, i) -> Int -> i -> Intforall i. Ix i => (i, i) -> Int -> i -> IntsafeIndex(il,iu)Intnii,e'e)|(i :: ii,e :: e'e)<-[(i, e')]ies]{-# INLINE(//)#-}{-|Takes an array and a list of pairs and returns an array identical tothe left argument except that it has been updated by the associationsin 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 withthe diagonal zeroed.As with the 'array' function, if any two associations in the list havethe 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 Haskell98 requires that for 'Array' the value at such indices is bottom.)For most array types, this operation is O(/n/) where /n/ is the sizeof the array. However, the diffarray package provides an array typefor which this operation has complexity linear in the number of updates.-}(//)::(IArrayae,Ixi)=>aie->[(i,e)]->aiearr :: a i earr// :: a i e -> [(i, e)] -> a i e//ies :: [(i, e)]ies=casea i e -> (i, i)forall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> (i, i)boundsa i earrof(l :: il,u :: iu)->a i e -> [(Int, e)] -> a i eforall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> [(Int, e)] -> a i eunsafeReplacea i earr[((i, i) -> Int -> i -> Intforall i. Ix i => (i, i) -> Int -> i -> IntsafeIndex(il,iu)(a i e -> Intforall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> IntnumElementsa i earr)ii,ee)|(i :: ii,e :: ee)<-[(i, e)]ies]{-# INLINEaccum#-}{-|@accum f@ takes an array and an association list and accumulates pairsfrom 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])-}accum::(IArrayae,Ixi)=>(e->e'->e)->aie->[(i,e')]->aieaccum :: (e -> e' -> e) -> a i e -> [(i, e')] -> a i eaccumf :: e -> e' -> efarr :: a i earries :: [(i, e')]ies=casea i e -> (i, i)forall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> (i, i)boundsa i earrof(l :: il,u :: iu)->letn :: Intn=a i e -> Intforall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> IntnumElementsa i earrin(e -> e' -> e) -> a i e -> [(Int, e')] -> a i eforall (a :: * -> * -> *) e i e'.(IArray a e, Ix i) =>(e -> e' -> e) -> a i e -> [(Int, e')] -> a i eunsafeAccume -> e' -> efa i earr[((i, i) -> Int -> i -> Intforall i. Ix i => (i, i) -> Int -> i -> IntsafeIndex(il,iu)Intnii,e'e)|(i :: ii,e :: e'e)<-[(i, e')]ies]{-# INLINEamap#-}-- | Returns a new array derived from the original array by applying a-- function to each of the elements.amap::(IArrayae',IArrayae,Ixi)=>(e'->e)->aie'->aieamap :: (e' -> e) -> a i e' -> a i eamapf :: e' -> efarr :: a i e'arr=casea i e' -> (i, i)forall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> (i, i)boundsa i e'arrof(l :: il,u :: iu)->letn :: Intn=a i e' -> Intforall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> IntnumElementsa i e'arrin(i, i) -> [(Int, e)] -> a i eforall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>(i, i) -> [(Int, e)] -> a i eunsafeArray(il,iu)[(Inti,e' -> ef(a i e' -> Int -> e'forall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> Int -> eunsafeAta i e'arrInti))|Inti<-[0..IntnInt -> Int -> Intforall a. Num a => a -> a -> a-1]]{-# INLINEixmap#-}-- | Returns a new array derived from the original array by applying a-- function to each of the indices.ixmap::(IArrayae,Ixi,Ixj)=>(i,i)->(i->j)->aje->aieixmap :: (i, i) -> (i -> j) -> a j e -> a i eixmap(l :: il,u :: iu)f :: i -> jfarr :: a j earr=(i, i) -> [(i, e)] -> a i eforall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>(i, i) -> [(i, e)] -> a i earray(il,iu)[(ii,a j earra j e -> j -> eforall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> i -> e!i -> jfii)|ii<-(i, i) -> [i]forall a. Ix a => (a, a) -> [a]range(il,iu)]------------------------------------------------------------------------------- Normal polymorphic arraysinstanceIArrayArr.Arrayewhere{-# INLINEbounds#-}bounds :: Array i e -> (i, i)bounds=Array i e -> (i, i)forall i e. Array i e -> (i, i)Arr.bounds{-# INLINEnumElements#-}numElements :: Array i e -> IntnumElements=Array i e -> Intforall i e. Array i e -> IntArr.numElements{-# INLINEunsafeArray#-}unsafeArray :: (i, i) -> [(Int, e)] -> Array i eunsafeArray=(i, i) -> [(Int, e)] -> Array i eforall i e. Ix i => (i, i) -> [(Int, e)] -> Array i eArr.unsafeArray{-# INLINEunsafeAt#-}unsafeAt :: Array i e -> Int -> eunsafeAt=Array i e -> Int -> eforall i e. Array i e -> Int -> eArr.unsafeAt{-# INLINEunsafeReplace#-}unsafeReplace :: Array i e -> [(Int, e)] -> Array i eunsafeReplace=Array i e -> [(Int, e)] -> Array i eforall i e. Array i e -> [(Int, e)] -> Array i eArr.unsafeReplace{-# INLINEunsafeAccum#-}unsafeAccum :: (e -> e' -> e) -> Array i e -> [(Int, e')] -> Array i eunsafeAccum=(e -> e' -> e) -> Array i e -> [(Int, e')] -> Array i eforall e a i. (e -> a -> e) -> Array i e -> [(Int, a)] -> Array i eArr.unsafeAccum{-# INLINEunsafeAccumArray#-}unsafeAccumArray :: (e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> Array i eunsafeAccumArray=(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> Array i eforall i e a.Ix i =>(e -> a -> e) -> e -> (i, i) -> [(Int, a)] -> Array i eArr.unsafeAccumArray------------------------------------------------------------------------------- Flat unboxed arrays-- | Arrays with unboxed elements. Instances of 'IArray' are provided-- for 'UArray' with certain element types ('Int', 'Float', 'Char',-- etc.; see the 'UArray' class for a full list).---- A 'UArray' will generally be more efficient (in terms of both time-- and space) than the equivalent 'Data.Array.Array' with the same-- element type. However, 'UArray' is strict in its elements - so-- don\'t use 'UArray' if you require the non-strictness that-- 'Data.Array.Array' provides.---- Because the @IArray@ interface provides operations overloaded on-- the type of the array, it should be possible to just change the-- array type being used by a program from say @Array@ to @UArray@ to-- get the benefits of unboxed arrays (don\'t forget to import-- "Data.Array.Unboxed" instead of "Data.Array").--dataUArrayie=UArray!i!i!IntByteArray#-- There are class-based invariants on both parameters. See also #9220.typeroleUArraynominalnominal{-# INLINEunsafeArrayUArray#-}unsafeArrayUArray::(MArray(STUArrays)e(STs),Ixi)=>(i,i)->[(Int,e)]->e->STs(UArrayie)unsafeArrayUArray :: (i, i) -> [(Int, e)] -> e -> ST s (UArray i e)unsafeArrayUArray(l :: il,u :: iu)ies :: [(Int, e)]iesdefault_elem :: edefault_elem=doSTUArray s i emarr<-(i, i) -> e -> ST s (STUArray s i e)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(il,iu)edefault_elem[ST s ()] -> ST s ()forall (t :: * -> *) (m :: * -> *) a.(Foldable t, Monad m) =>t (m a) -> m ()sequence_[STUArray s i e -> Int -> e -> ST s ()forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> e -> m ()unsafeWriteSTUArray s i emarrIntiee|(i :: Inti,e :: ee)<-[(Int, e)]ies]STUArray s i e -> ST s (UArray i e)forall s i e. STUArray s i e -> ST s (UArray i e)unsafeFreezeSTUArraySTUArray s i emarr{-# INLINEunsafeFreezeSTUArray#-}unsafeFreezeSTUArray::STUArraysie->STs(UArrayie)unsafeFreezeSTUArray :: STUArray s i e -> ST s (UArray i e)unsafeFreezeSTUArray(STUArrayl :: ilu :: iun :: Intnmarr# :: MutableByteArray# smarr#)=STRep s (UArray i e) -> ST s (UArray i e)forall s a. STRep s a -> ST s aST(STRep s (UArray i e) -> ST s (UArray i e))-> STRep s (UArray i e) -> ST s (UArray i e)forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> State# s -> (# State# s, ByteArray# #)forall d.MutableByteArray# d -> State# d -> (# State# d, ByteArray# #)unsafeFreezeByteArray#MutableByteArray# smarr#State# ss1#of{(#s2# :: State# ss2#,arr# :: ByteArray#arr##)->(#State# ss2#,i -> i -> Int -> ByteArray# -> UArray i eforall i e. i -> i -> Int -> ByteArray# -> UArray i eUArrayiliuIntnByteArray#arr##)}{-# INLINEunsafeReplaceUArray#-}unsafeReplaceUArray::(MArray(STUArrays)e(STs),Ixi)=>UArrayie->[(Int,e)]->STs(UArrayie)unsafeReplaceUArray :: UArray i e -> [(Int, e)] -> ST s (UArray i e)unsafeReplaceUArrayarr :: UArray i earries :: [(Int, e)]ies=doSTUArray s i emarr<-UArray i e -> ST s (STUArray s i e)forall i e s. UArray i e -> ST s (STUArray s i e)thawSTUArrayUArray i earr[ST s ()] -> ST s ()forall (t :: * -> *) (m :: * -> *) a.(Foldable t, Monad m) =>t (m a) -> m ()sequence_[STUArray s i e -> Int -> e -> ST s ()forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> e -> m ()unsafeWriteSTUArray s i emarrIntiee|(i :: Inti,e :: ee)<-[(Int, e)]ies]STUArray s i e -> ST s (UArray i e)forall s i e. STUArray s i e -> ST s (UArray i e)unsafeFreezeSTUArraySTUArray s i emarr{-# INLINEunsafeAccumUArray#-}unsafeAccumUArray::(MArray(STUArrays)e(STs),Ixi)=>(e->e'->e)->UArrayie->[(Int,e')]->STs(UArrayie)unsafeAccumUArray :: (e -> e' -> e) -> UArray i e -> [(Int, e')] -> ST s (UArray i e)unsafeAccumUArrayf :: e -> e' -> efarr :: UArray i earries :: [(Int, e')]ies=doSTUArray s i emarr<-UArray i e -> ST s (STUArray s i e)forall i e s. UArray i e -> ST s (STUArray s i e)thawSTUArrayUArray i earr[ST s ()] -> ST s ()forall (t :: * -> *) (m :: * -> *) a.(Foldable t, Monad m) =>t (m a) -> m ()sequence_[doeold<-STUArray s i e -> Int -> ST s eforall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> m eunsafeReadSTUArray s i emarrIntiSTUArray s i e -> Int -> e -> ST s ()forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> e -> m ()unsafeWriteSTUArray s i emarrInti(e -> e' -> efeolde'new)|(i :: Inti,new :: e'new)<-[(Int, e')]ies]STUArray s i e -> ST s (UArray i e)forall s i e. STUArray s i e -> ST s (UArray i e)unsafeFreezeSTUArraySTUArray s i emarr{-# INLINEunsafeAccumArrayUArray#-}unsafeAccumArrayUArray::(MArray(STUArrays)e(STs),Ixi)=>(e->e'->e)->e->(i,i)->[(Int,e')]->STs(UArrayie)unsafeAccumArrayUArray :: (e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> ST s (UArray i e)unsafeAccumArrayUArrayf :: e -> e' -> efinitialValue :: einitialValue(l :: il,u :: iu)ies :: [(Int, e')]ies=doSTUArray s i emarr<-(i, i) -> e -> ST s (STUArray s i e)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(il,iu)einitialValue[ST s ()] -> ST s ()forall (t :: * -> *) (m :: * -> *) a.(Foldable t, Monad m) =>t (m a) -> m ()sequence_[doeold<-STUArray s i e -> Int -> ST s eforall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> m eunsafeReadSTUArray s i emarrIntiSTUArray s i e -> Int -> e -> ST s ()forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> e -> m ()unsafeWriteSTUArray s i emarrInti(e -> e' -> efeolde'new)|(i :: Inti,new :: e'new)<-[(Int, e')]ies]STUArray s i e -> ST s (UArray i e)forall s i e. STUArray s i e -> ST s (UArray i e)unsafeFreezeSTUArraySTUArray s i emarr{-# INLINEeqUArray#-}eqUArray::(IArrayUArraye,Ixi,Eqe)=>UArrayie->UArrayie->BooleqUArray :: UArray i e -> UArray i e -> BooleqUArrayarr1 :: UArray i earr1@(UArrayl1 :: il1u1 :: iu1n1 :: Intn1_)arr2 :: UArray i earr2@(UArrayl2 :: il2u2 :: iu2n2 :: Intn2_)=ifIntn1Int -> Int -> Boolforall a. Eq a => a -> a -> Bool==0thenIntn2Int -> Int -> Boolforall a. Eq a => a -> a -> Bool==0elseil1i -> i -> Boolforall a. Eq a => a -> a -> Bool==il2Bool -> Bool -> Bool&&iu1i -> i -> Boolforall a. Eq a => a -> a -> Bool==iu2Bool -> Bool -> Bool&&[Bool] -> Boolforall (t :: * -> *). Foldable t => t Bool -> Booland[UArray i e -> Int -> eforall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> Int -> eunsafeAtUArray i earr1Intie -> e -> Boolforall a. Eq a => a -> a -> Bool==UArray i e -> Int -> eforall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> Int -> eunsafeAtUArray i earr2Inti|Inti<-[0..Intn1Int -> Int -> Intforall a. Num a => a -> a -> a-1]]{-# INLINE[1]cmpUArray#-}cmpUArray::(IArrayUArraye,Ixi,Orde)=>UArrayie->UArrayie->OrderingcmpUArray :: UArray i e -> UArray i e -> OrderingcmpUArrayarr1 :: UArray i earr1arr2 :: UArray i earr2=[(i, e)] -> [(i, e)] -> Orderingforall a. Ord a => a -> a -> Orderingcompare(UArray i e -> [(i, e)]forall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> [(i, e)]assocsUArray i earr1)(UArray i e -> [(i, e)]forall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> [(i, e)]assocsUArray i earr2){-# INLINEcmpIntUArray#-}cmpIntUArray::(IArrayUArraye,Orde)=>UArrayInte->UArrayInte->OrderingcmpIntUArray :: UArray Int e -> UArray Int e -> OrderingcmpIntUArrayarr1 :: UArray Int earr1@(UArrayl1 :: Intl1u1 :: Intu1n1 :: Intn1_)arr2 :: UArray Int earr2@(UArrayl2 :: Intl2u2 :: Intu2n2 :: Intn2_)=ifIntn1Int -> Int -> Boolforall a. Eq a => a -> a -> Bool==0thenifIntn2Int -> Int -> Boolforall a. Eq a => a -> a -> Bool==0thenOrderingEQelseOrderingLTelseifIntn2Int -> Int -> Boolforall a. Eq a => a -> a -> Bool==0thenOrderingGTelsecaseInt -> Int -> Orderingforall a. Ord a => a -> a -> OrderingcompareIntl1Intl2ofEQ->(Int -> Ordering -> Ordering) -> Ordering -> [Int] -> Orderingforall (t :: * -> *) a b.Foldable t =>(a -> b -> b) -> b -> t a -> bfoldrInt -> Ordering -> Orderingcmp(Int -> Int -> Orderingforall a. Ord a => a -> a -> OrderingcompareIntu1Intu2)[0..(Intn1Int -> Int -> Intforall a. Ord a => a -> a -> a`min`Intn2)Int -> Int -> Intforall a. Num a => a -> a -> a-1]other :: Orderingother->Orderingotherwherecmp :: Int -> Ordering -> Orderingcmpi :: Intirest :: Orderingrest=casee -> e -> Orderingforall a. Ord a => a -> a -> Orderingcompare(UArray Int e -> Int -> eforall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> Int -> eunsafeAtUArray Int earr1Inti)(UArray Int e -> Int -> eforall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> Int -> eunsafeAtUArray Int earr2Inti)ofEQ->Orderingrestother :: Orderingother->Orderingother{-# RULES"cmpUArray/Int"cmpUArray=cmpIntUArray#-}------------------------------------------------------------------------------- Showing and Reading IArrays{-# SPECIALISEshowsIArray::(IArrayUArraye,Ixi,Showi,Showe)=>Int->UArrayie->ShowS#-}showsIArray::(IArrayae,Ixi,Showi,Showe)=>Int->aie->ShowSshowsIArray :: Int -> a i e -> [Char] -> [Char]showsIArrayp :: Intpa :: a i ea=Bool -> ([Char] -> [Char]) -> [Char] -> [Char]showParen(IntpInt -> Int -> Boolforall a. Ord a => a -> a -> Bool>IntappPrec)(([Char] -> [Char]) -> [Char] -> [Char])-> ([Char] -> [Char]) -> [Char] -> [Char]forall a b. (a -> b) -> a -> b$[Char] -> [Char] -> [Char]showString"array "([Char] -> [Char]) -> ([Char] -> [Char]) -> [Char] -> [Char]forall b c a. (b -> c) -> (a -> b) -> a -> c.(i, i) -> [Char] -> [Char]forall a. Show a => a -> [Char] -> [Char]shows(a i e -> (i, i)forall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> (i, i)boundsa i ea)([Char] -> [Char]) -> ([Char] -> [Char]) -> [Char] -> [Char]forall b c a. (b -> c) -> (a -> b) -> a -> c.Char -> [Char] -> [Char]showChar' '([Char] -> [Char]) -> ([Char] -> [Char]) -> [Char] -> [Char]forall b c a. (b -> c) -> (a -> b) -> a -> c.[(i, e)] -> [Char] -> [Char]forall a. Show a => a -> [Char] -> [Char]shows(a i e -> [(i, e)]forall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> [(i, e)]assocsa i ea){-# SPECIALISEreadIArray::(IArrayUArraye,Ixi,Readi,Reade)=>ReadPrec(UArrayie)#-}readIArray::(IArrayae,Ixi,Readi,Reade)=>ReadPrec(aie)readIArray :: ReadPrec (a i e)readIArray=ReadPrec (a i e) -> ReadPrec (a i e)forall a. ReadPrec a -> ReadPrec aparens(ReadPrec (a i e) -> ReadPrec (a i e))-> ReadPrec (a i e) -> ReadPrec (a i e)forall a b. (a -> b) -> a -> b$Int -> ReadPrec (a i e) -> ReadPrec (a i e)forall a. Int -> ReadPrec a -> ReadPrec aprecIntappPrec(ReadPrec (a i e) -> ReadPrec (a i e))-> ReadPrec (a i e) -> ReadPrec (a i e)forall a b. (a -> b) -> a -> b$doLexeme -> ReadPrec ()expectP([Char] -> LexemeIdent"array")(i, i)theBounds<-ReadPrec (i, i) -> ReadPrec (i, i)forall a. ReadPrec a -> ReadPrec astepReadPrec (i, i)forall a. Read a => ReadPrec areadPrec[(i, e)]vals<-ReadPrec [(i, e)] -> ReadPrec [(i, e)]forall a. ReadPrec a -> ReadPrec astepReadPrec [(i, e)]forall a. Read a => ReadPrec areadPreca i e -> ReadPrec (a i e)forall (m :: * -> *) a. Monad m => a -> m areturn((i, i) -> [(i, e)] -> a i eforall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>(i, i) -> [(i, e)] -> a i earray(i, i)theBounds[(i, e)]vals)------------------------------------------------------------------------------- Flat unboxed arrays: instancesinstanceIArrayUArrayBoolwhere{-# INLINEbounds#-}bounds :: UArray i Bool -> (i, i)bounds(UArrayl :: ilu :: iu__)=(il,iu){-# INLINEnumElements#-}numElements :: UArray i Bool -> IntnumElements(UArray__n :: Intn_)=Intn{-# INLINEunsafeArray#-}unsafeArray :: (i, i) -> [(Int, Bool)] -> UArray i BoolunsafeArraylu :: (i, i)luies :: [(Int, Bool)]ies=(forall s. ST s (UArray i Bool)) -> UArray i Boolforall a. (forall s. ST s a) -> arunST((i, i) -> [(Int, Bool)] -> Bool -> ST s (UArray i Bool)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>(i, i) -> [(Int, e)] -> e -> ST s (UArray i e)unsafeArrayUArray(i, i)lu[(Int, Bool)]iesBoolFalse){-# INLINEunsafeAt#-}unsafeAt :: UArray i Bool -> Int -> BoolunsafeAt(UArray___arr# :: ByteArray#arr#)(I#i# :: Int#i#)=Int# -> BoolisTrue#((ByteArray# -> Int# -> Word#indexWordArray#ByteArray#arr#(Int# -> Int#bOOL_INDEXInt#i#)Word# -> Word# -> Word#`and#`Int# -> Word#bOOL_BITInt#i#)Word# -> Word# -> Int#`neWord#`Int# -> Word#int2Word#0#){-# INLINEunsafeReplace#-}unsafeReplace :: UArray i Bool -> [(Int, Bool)] -> UArray i BoolunsafeReplacearr :: UArray i Boolarries :: [(Int, Bool)]ies=(forall s. ST s (UArray i Bool)) -> UArray i Boolforall a. (forall s. ST s a) -> arunST(UArray i Bool -> [(Int, Bool)] -> ST s (UArray i Bool)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>UArray i e -> [(Int, e)] -> ST s (UArray i e)unsafeReplaceUArrayUArray i Boolarr[(Int, Bool)]ies){-# INLINEunsafeAccum#-}unsafeAccum :: (Bool -> e' -> Bool)-> UArray i Bool -> [(Int, e')] -> UArray i BoolunsafeAccumf :: Bool -> e' -> Boolfarr :: UArray i Boolarries :: [(Int, e')]ies=(forall s. ST s (UArray i Bool)) -> UArray i Boolforall a. (forall s. ST s a) -> arunST((Bool -> e' -> Bool)-> UArray i Bool -> [(Int, e')] -> ST s (UArray i Bool)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> UArray i e -> [(Int, e')] -> ST s (UArray i e)unsafeAccumUArrayBool -> e' -> BoolfUArray i Boolarr[(Int, e')]ies){-# INLINEunsafeAccumArray#-}unsafeAccumArray :: (Bool -> e' -> Bool)-> Bool -> (i, i) -> [(Int, e')] -> UArray i BoolunsafeAccumArrayf :: Bool -> e' -> BoolfinitialValue :: BoolinitialValuelu :: (i, i)luies :: [(Int, e')]ies=(forall s. ST s (UArray i Bool)) -> UArray i Boolforall a. (forall s. ST s a) -> arunST((Bool -> e' -> Bool)-> Bool -> (i, i) -> [(Int, e')] -> ST s (UArray i Bool)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> ST s (UArray i e)unsafeAccumArrayUArrayBool -> e' -> BoolfBoolinitialValue(i, i)lu[(Int, e')]ies)instanceIArrayUArrayCharwhere{-# INLINEbounds#-}bounds :: UArray i Char -> (i, i)bounds(UArrayl :: ilu :: iu__)=(il,iu){-# INLINEnumElements#-}numElements :: UArray i Char -> IntnumElements(UArray__n :: Intn_)=Intn{-# INLINEunsafeArray#-}unsafeArray :: (i, i) -> [(Int, Char)] -> UArray i CharunsafeArraylu :: (i, i)luies :: [(Int, Char)]ies=(forall s. ST s (UArray i Char)) -> UArray i Charforall a. (forall s. ST s a) -> arunST((i, i) -> [(Int, Char)] -> Char -> ST s (UArray i Char)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>(i, i) -> [(Int, e)] -> e -> ST s (UArray i e)unsafeArrayUArray(i, i)lu[(Int, Char)]ies'\0'){-# INLINEunsafeAt#-}unsafeAt :: UArray i Char -> Int -> CharunsafeAt(UArray___arr# :: ByteArray#arr#)(I#i# :: Int#i#)=Char# -> CharC#(ByteArray# -> Int# -> Char#indexWideCharArray#ByteArray#arr#Int#i#){-# INLINEunsafeReplace#-}unsafeReplace :: UArray i Char -> [(Int, Char)] -> UArray i CharunsafeReplacearr :: UArray i Chararries :: [(Int, Char)]ies=(forall s. ST s (UArray i Char)) -> UArray i Charforall a. (forall s. ST s a) -> arunST(UArray i Char -> [(Int, Char)] -> ST s (UArray i Char)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>UArray i e -> [(Int, e)] -> ST s (UArray i e)unsafeReplaceUArrayUArray i Chararr[(Int, Char)]ies){-# INLINEunsafeAccum#-}unsafeAccum :: (Char -> e' -> Char)-> UArray i Char -> [(Int, e')] -> UArray i CharunsafeAccumf :: Char -> e' -> Charfarr :: UArray i Chararries :: [(Int, e')]ies=(forall s. ST s (UArray i Char)) -> UArray i Charforall a. (forall s. ST s a) -> arunST((Char -> e' -> Char)-> UArray i Char -> [(Int, e')] -> ST s (UArray i Char)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> UArray i e -> [(Int, e')] -> ST s (UArray i e)unsafeAccumUArrayChar -> e' -> CharfUArray i Chararr[(Int, e')]ies){-# INLINEunsafeAccumArray#-}unsafeAccumArray :: (Char -> e' -> Char)-> Char -> (i, i) -> [(Int, e')] -> UArray i CharunsafeAccumArrayf :: Char -> e' -> CharfinitialValue :: CharinitialValuelu :: (i, i)luies :: [(Int, e')]ies=(forall s. ST s (UArray i Char)) -> UArray i Charforall a. (forall s. ST s a) -> arunST((Char -> e' -> Char)-> Char -> (i, i) -> [(Int, e')] -> ST s (UArray i Char)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> ST s (UArray i e)unsafeAccumArrayUArrayChar -> e' -> CharfCharinitialValue(i, i)lu[(Int, e')]ies)instanceIArrayUArrayIntwhere{-# INLINEbounds#-}bounds :: UArray i Int -> (i, i)bounds(UArrayl :: ilu :: iu__)=(il,iu){-# INLINEnumElements#-}numElements :: UArray i Int -> IntnumElements(UArray__n :: Intn_)=Intn{-# INLINEunsafeArray#-}unsafeArray :: (i, i) -> [(Int, Int)] -> UArray i IntunsafeArraylu :: (i, i)luies :: [(Int, Int)]ies=(forall s. ST s (UArray i Int)) -> UArray i Intforall a. (forall s. ST s a) -> arunST((i, i) -> [(Int, Int)] -> Int -> ST s (UArray i Int)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>(i, i) -> [(Int, e)] -> e -> ST s (UArray i e)unsafeArrayUArray(i, i)lu[(Int, Int)]ies0){-# INLINEunsafeAt#-}unsafeAt :: UArray i Int -> Int -> IntunsafeAt(UArray___arr# :: ByteArray#arr#)(I#i# :: Int#i#)=Int# -> IntI#(ByteArray# -> Int# -> Int#indexIntArray#ByteArray#arr#Int#i#){-# INLINEunsafeReplace#-}unsafeReplace :: UArray i Int -> [(Int, Int)] -> UArray i IntunsafeReplacearr :: UArray i Intarries :: [(Int, Int)]ies=(forall s. ST s (UArray i Int)) -> UArray i Intforall a. (forall s. ST s a) -> arunST(UArray i Int -> [(Int, Int)] -> ST s (UArray i Int)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>UArray i e -> [(Int, e)] -> ST s (UArray i e)unsafeReplaceUArrayUArray i Intarr[(Int, Int)]ies){-# INLINEunsafeAccum#-}unsafeAccum :: (Int -> e' -> Int) -> UArray i Int -> [(Int, e')] -> UArray i IntunsafeAccumf :: Int -> e' -> Intfarr :: UArray i Intarries :: [(Int, e')]ies=(forall s. ST s (UArray i Int)) -> UArray i Intforall a. (forall s. ST s a) -> arunST((Int -> e' -> Int)-> UArray i Int -> [(Int, e')] -> ST s (UArray i Int)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> UArray i e -> [(Int, e')] -> ST s (UArray i e)unsafeAccumUArrayInt -> e' -> IntfUArray i Intarr[(Int, e')]ies){-# INLINEunsafeAccumArray#-}unsafeAccumArray :: (Int -> e' -> Int) -> Int -> (i, i) -> [(Int, e')] -> UArray i IntunsafeAccumArrayf :: Int -> e' -> IntfinitialValue :: IntinitialValuelu :: (i, i)luies :: [(Int, e')]ies=(forall s. ST s (UArray i Int)) -> UArray i Intforall a. (forall s. ST s a) -> arunST((Int -> e' -> Int)-> Int -> (i, i) -> [(Int, e')] -> ST s (UArray i Int)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> ST s (UArray i e)unsafeAccumArrayUArrayInt -> e' -> IntfIntinitialValue(i, i)lu[(Int, e')]ies)instanceIArrayUArrayWordwhere{-# INLINEbounds#-}bounds :: UArray i Word -> (i, i)bounds(UArrayl :: ilu :: iu__)=(il,iu){-# INLINEnumElements#-}numElements :: UArray i Word -> IntnumElements(UArray__n :: Intn_)=Intn{-# INLINEunsafeArray#-}unsafeArray :: (i, i) -> [(Int, Word)] -> UArray i WordunsafeArraylu :: (i, i)luies :: [(Int, Word)]ies=(forall s. ST s (UArray i Word)) -> UArray i Wordforall a. (forall s. ST s a) -> arunST((i, i) -> [(Int, Word)] -> Word -> ST s (UArray i Word)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>(i, i) -> [(Int, e)] -> e -> ST s (UArray i e)unsafeArrayUArray(i, i)lu[(Int, Word)]ies0){-# INLINEunsafeAt#-}unsafeAt :: UArray i Word -> Int -> WordunsafeAt(UArray___arr# :: ByteArray#arr#)(I#i# :: Int#i#)=Word# -> WordW#(ByteArray# -> Int# -> Word#indexWordArray#ByteArray#arr#Int#i#){-# INLINEunsafeReplace#-}unsafeReplace :: UArray i Word -> [(Int, Word)] -> UArray i WordunsafeReplacearr :: UArray i Wordarries :: [(Int, Word)]ies=(forall s. ST s (UArray i Word)) -> UArray i Wordforall a. (forall s. ST s a) -> arunST(UArray i Word -> [(Int, Word)] -> ST s (UArray i Word)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>UArray i e -> [(Int, e)] -> ST s (UArray i e)unsafeReplaceUArrayUArray i Wordarr[(Int, Word)]ies){-# INLINEunsafeAccum#-}unsafeAccum :: (Word -> e' -> Word)-> UArray i Word -> [(Int, e')] -> UArray i WordunsafeAccumf :: Word -> e' -> Wordfarr :: UArray i Wordarries :: [(Int, e')]ies=(forall s. ST s (UArray i Word)) -> UArray i Wordforall a. (forall s. ST s a) -> arunST((Word -> e' -> Word)-> UArray i Word -> [(Int, e')] -> ST s (UArray i Word)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> UArray i e -> [(Int, e')] -> ST s (UArray i e)unsafeAccumUArrayWord -> e' -> WordfUArray i Wordarr[(Int, e')]ies){-# INLINEunsafeAccumArray#-}unsafeAccumArray :: (Word -> e' -> Word)-> Word -> (i, i) -> [(Int, e')] -> UArray i WordunsafeAccumArrayf :: Word -> e' -> WordfinitialValue :: WordinitialValuelu :: (i, i)luies :: [(Int, e')]ies=(forall s. ST s (UArray i Word)) -> UArray i Wordforall a. (forall s. ST s a) -> arunST((Word -> e' -> Word)-> Word -> (i, i) -> [(Int, e')] -> ST s (UArray i Word)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> ST s (UArray i e)unsafeAccumArrayUArrayWord -> e' -> WordfWordinitialValue(i, i)lu[(Int, e')]ies)instanceIArrayUArray(Ptra)where{-# INLINEbounds#-}bounds :: UArray i (Ptr a) -> (i, i)bounds(UArrayl :: ilu :: iu__)=(il,iu){-# INLINEnumElements#-}numElements :: UArray i (Ptr a) -> IntnumElements(UArray__n :: Intn_)=Intn{-# INLINEunsafeArray#-}unsafeArray :: (i, i) -> [(Int, Ptr a)] -> UArray i (Ptr a)unsafeArraylu :: (i, i)luies :: [(Int, Ptr a)]ies=(forall s. ST s (UArray i (Ptr a))) -> UArray i (Ptr a)forall a. (forall s. ST s a) -> arunST((i, i) -> [(Int, Ptr a)] -> Ptr a -> ST s (UArray i (Ptr a))forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>(i, i) -> [(Int, e)] -> e -> ST s (UArray i e)unsafeArrayUArray(i, i)lu[(Int, Ptr a)]iesPtr aforall a. Ptr anullPtr){-# INLINEunsafeAt#-}unsafeAt :: UArray i (Ptr a) -> Int -> Ptr aunsafeAt(UArray___arr# :: ByteArray#arr#)(I#i# :: Int#i#)=Addr# -> Ptr aforall a. Addr# -> Ptr aPtr(ByteArray# -> Int# -> Addr#indexAddrArray#ByteArray#arr#Int#i#){-# INLINEunsafeReplace#-}unsafeReplace :: UArray i (Ptr a) -> [(Int, Ptr a)] -> UArray i (Ptr a)unsafeReplacearr :: UArray i (Ptr a)arries :: [(Int, Ptr a)]ies=(forall s. ST s (UArray i (Ptr a))) -> UArray i (Ptr a)forall a. (forall s. ST s a) -> arunST(UArray i (Ptr a) -> [(Int, Ptr a)] -> ST s (UArray i (Ptr a))forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>UArray i e -> [(Int, e)] -> ST s (UArray i e)unsafeReplaceUArrayUArray i (Ptr a)arr[(Int, Ptr a)]ies){-# INLINEunsafeAccum#-}unsafeAccum :: (Ptr a -> e' -> Ptr a)-> UArray i (Ptr a) -> [(Int, e')] -> UArray i (Ptr a)unsafeAccumf :: Ptr a -> e' -> Ptr afarr :: UArray i (Ptr a)arries :: [(Int, e')]ies=(forall s. ST s (UArray i (Ptr a))) -> UArray i (Ptr a)forall a. (forall s. ST s a) -> arunST((Ptr a -> e' -> Ptr a)-> UArray i (Ptr a) -> [(Int, e')] -> ST s (UArray i (Ptr a))forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> UArray i e -> [(Int, e')] -> ST s (UArray i e)unsafeAccumUArrayPtr a -> e' -> Ptr afUArray i (Ptr a)arr[(Int, e')]ies){-# INLINEunsafeAccumArray#-}unsafeAccumArray :: (Ptr a -> e' -> Ptr a)-> Ptr a -> (i, i) -> [(Int, e')] -> UArray i (Ptr a)unsafeAccumArrayf :: Ptr a -> e' -> Ptr afinitialValue :: Ptr ainitialValuelu :: (i, i)luies :: [(Int, e')]ies=(forall s. ST s (UArray i (Ptr a))) -> UArray i (Ptr a)forall a. (forall s. ST s a) -> arunST((Ptr a -> e' -> Ptr a)-> Ptr a -> (i, i) -> [(Int, e')] -> ST s (UArray i (Ptr a))forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> ST s (UArray i e)unsafeAccumArrayUArrayPtr a -> e' -> Ptr afPtr ainitialValue(i, i)lu[(Int, e')]ies)instanceIArrayUArray(FunPtra)where{-# INLINEbounds#-}bounds :: UArray i (FunPtr a) -> (i, i)bounds(UArrayl :: ilu :: iu__)=(il,iu){-# INLINEnumElements#-}numElements :: UArray i (FunPtr a) -> IntnumElements(UArray__n :: Intn_)=Intn{-# INLINEunsafeArray#-}unsafeArray :: (i, i) -> [(Int, FunPtr a)] -> UArray i (FunPtr a)unsafeArraylu :: (i, i)luies :: [(Int, FunPtr a)]ies=(forall s. ST s (UArray i (FunPtr a))) -> UArray i (FunPtr a)forall a. (forall s. ST s a) -> arunST((i, i)-> [(Int, FunPtr a)] -> FunPtr a -> ST s (UArray i (FunPtr a))forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>(i, i) -> [(Int, e)] -> e -> ST s (UArray i e)unsafeArrayUArray(i, i)lu[(Int, FunPtr a)]iesFunPtr aforall a. FunPtr anullFunPtr){-# INLINEunsafeAt#-}unsafeAt :: UArray i (FunPtr a) -> Int -> FunPtr aunsafeAt(UArray___arr# :: ByteArray#arr#)(I#i# :: Int#i#)=Addr# -> FunPtr aforall a. Addr# -> FunPtr aFunPtr(ByteArray# -> Int# -> Addr#indexAddrArray#ByteArray#arr#Int#i#){-# INLINEunsafeReplace#-}unsafeReplace :: UArray i (FunPtr a) -> [(Int, FunPtr a)] -> UArray i (FunPtr a)unsafeReplacearr :: UArray i (FunPtr a)arries :: [(Int, FunPtr a)]ies=(forall s. ST s (UArray i (FunPtr a))) -> UArray i (FunPtr a)forall a. (forall s. ST s a) -> arunST(UArray i (FunPtr a)-> [(Int, FunPtr a)] -> ST s (UArray i (FunPtr a))forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>UArray i e -> [(Int, e)] -> ST s (UArray i e)unsafeReplaceUArrayUArray i (FunPtr a)arr[(Int, FunPtr a)]ies){-# INLINEunsafeAccum#-}unsafeAccum :: (FunPtr a -> e' -> FunPtr a)-> UArray i (FunPtr a) -> [(Int, e')] -> UArray i (FunPtr a)unsafeAccumf :: FunPtr a -> e' -> FunPtr afarr :: UArray i (FunPtr a)arries :: [(Int, e')]ies=(forall s. ST s (UArray i (FunPtr a))) -> UArray i (FunPtr a)forall a. (forall s. ST s a) -> arunST((FunPtr a -> e' -> FunPtr a)-> UArray i (FunPtr a) -> [(Int, e')] -> ST s (UArray i (FunPtr a))forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> UArray i e -> [(Int, e')] -> ST s (UArray i e)unsafeAccumUArrayFunPtr a -> e' -> FunPtr afUArray i (FunPtr a)arr[(Int, e')]ies){-# INLINEunsafeAccumArray#-}unsafeAccumArray :: (FunPtr a -> e' -> FunPtr a)-> FunPtr a -> (i, i) -> [(Int, e')] -> UArray i (FunPtr a)unsafeAccumArrayf :: FunPtr a -> e' -> FunPtr afinitialValue :: FunPtr ainitialValuelu :: (i, i)luies :: [(Int, e')]ies=(forall s. ST s (UArray i (FunPtr a))) -> UArray i (FunPtr a)forall a. (forall s. ST s a) -> arunST((FunPtr a -> e' -> FunPtr a)-> FunPtr a -> (i, i) -> [(Int, e')] -> ST s (UArray i (FunPtr a))forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> ST s (UArray i e)unsafeAccumArrayUArrayFunPtr a -> e' -> FunPtr afFunPtr ainitialValue(i, i)lu[(Int, e')]ies)instanceIArrayUArrayFloatwhere{-# INLINEbounds#-}bounds :: UArray i Float -> (i, i)bounds(UArrayl :: ilu :: iu__)=(il,iu){-# INLINEnumElements#-}numElements :: UArray i Float -> IntnumElements(UArray__n :: Intn_)=Intn{-# INLINEunsafeArray#-}unsafeArray :: (i, i) -> [(Int, Float)] -> UArray i FloatunsafeArraylu :: (i, i)luies :: [(Int, Float)]ies=(forall s. ST s (UArray i Float)) -> UArray i Floatforall a. (forall s. ST s a) -> arunST((i, i) -> [(Int, Float)] -> Float -> ST s (UArray i Float)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>(i, i) -> [(Int, e)] -> e -> ST s (UArray i e)unsafeArrayUArray(i, i)lu[(Int, Float)]ies0){-# INLINEunsafeAt#-}unsafeAt :: UArray i Float -> Int -> FloatunsafeAt(UArray___arr# :: ByteArray#arr#)(I#i# :: Int#i#)=Float# -> FloatF#(ByteArray# -> Int# -> Float#indexFloatArray#ByteArray#arr#Int#i#){-# INLINEunsafeReplace#-}unsafeReplace :: UArray i Float -> [(Int, Float)] -> UArray i FloatunsafeReplacearr :: UArray i Floatarries :: [(Int, Float)]ies=(forall s. ST s (UArray i Float)) -> UArray i Floatforall a. (forall s. ST s a) -> arunST(UArray i Float -> [(Int, Float)] -> ST s (UArray i Float)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>UArray i e -> [(Int, e)] -> ST s (UArray i e)unsafeReplaceUArrayUArray i Floatarr[(Int, Float)]ies){-# INLINEunsafeAccum#-}unsafeAccum :: (Float -> e' -> Float)-> UArray i Float -> [(Int, e')] -> UArray i FloatunsafeAccumf :: Float -> e' -> Floatfarr :: UArray i Floatarries :: [(Int, e')]ies=(forall s. ST s (UArray i Float)) -> UArray i Floatforall a. (forall s. ST s a) -> arunST((Float -> e' -> Float)-> UArray i Float -> [(Int, e')] -> ST s (UArray i Float)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> UArray i e -> [(Int, e')] -> ST s (UArray i e)unsafeAccumUArrayFloat -> e' -> FloatfUArray i Floatarr[(Int, e')]ies){-# INLINEunsafeAccumArray#-}unsafeAccumArray :: (Float -> e' -> Float)-> Float -> (i, i) -> [(Int, e')] -> UArray i FloatunsafeAccumArrayf :: Float -> e' -> FloatfinitialValue :: FloatinitialValuelu :: (i, i)luies :: [(Int, e')]ies=(forall s. ST s (UArray i Float)) -> UArray i Floatforall a. (forall s. ST s a) -> arunST((Float -> e' -> Float)-> Float -> (i, i) -> [(Int, e')] -> ST s (UArray i Float)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> ST s (UArray i e)unsafeAccumArrayUArrayFloat -> e' -> FloatfFloatinitialValue(i, i)lu[(Int, e')]ies)instanceIArrayUArrayDoublewhere{-# INLINEbounds#-}bounds :: UArray i Double -> (i, i)bounds(UArrayl :: ilu :: iu__)=(il,iu){-# INLINEnumElements#-}numElements :: UArray i Double -> IntnumElements(UArray__n :: Intn_)=Intn{-# INLINEunsafeArray#-}unsafeArray :: (i, i) -> [(Int, Double)] -> UArray i DoubleunsafeArraylu :: (i, i)luies :: [(Int, Double)]ies=(forall s. ST s (UArray i Double)) -> UArray i Doubleforall a. (forall s. ST s a) -> arunST((i, i) -> [(Int, Double)] -> Double -> ST s (UArray i Double)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>(i, i) -> [(Int, e)] -> e -> ST s (UArray i e)unsafeArrayUArray(i, i)lu[(Int, Double)]ies0){-# INLINEunsafeAt#-}unsafeAt :: UArray i Double -> Int -> DoubleunsafeAt(UArray___arr# :: ByteArray#arr#)(I#i# :: Int#i#)=Double# -> DoubleD#(ByteArray# -> Int# -> Double#indexDoubleArray#ByteArray#arr#Int#i#){-# INLINEunsafeReplace#-}unsafeReplace :: UArray i Double -> [(Int, Double)] -> UArray i DoubleunsafeReplacearr :: UArray i Doublearries :: [(Int, Double)]ies=(forall s. ST s (UArray i Double)) -> UArray i Doubleforall a. (forall s. ST s a) -> arunST(UArray i Double -> [(Int, Double)] -> ST s (UArray i Double)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>UArray i e -> [(Int, e)] -> ST s (UArray i e)unsafeReplaceUArrayUArray i Doublearr[(Int, Double)]ies){-# INLINEunsafeAccum#-}unsafeAccum :: (Double -> e' -> Double)-> UArray i Double -> [(Int, e')] -> UArray i DoubleunsafeAccumf :: Double -> e' -> Doublefarr :: UArray i Doublearries :: [(Int, e')]ies=(forall s. ST s (UArray i Double)) -> UArray i Doubleforall a. (forall s. ST s a) -> arunST((Double -> e' -> Double)-> UArray i Double -> [(Int, e')] -> ST s (UArray i Double)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> UArray i e -> [(Int, e')] -> ST s (UArray i e)unsafeAccumUArrayDouble -> e' -> DoublefUArray i Doublearr[(Int, e')]ies){-# INLINEunsafeAccumArray#-}unsafeAccumArray :: (Double -> e' -> Double)-> Double -> (i, i) -> [(Int, e')] -> UArray i DoubleunsafeAccumArrayf :: Double -> e' -> DoublefinitialValue :: DoubleinitialValuelu :: (i, i)luies :: [(Int, e')]ies=(forall s. ST s (UArray i Double)) -> UArray i Doubleforall a. (forall s. ST s a) -> arunST((Double -> e' -> Double)-> Double -> (i, i) -> [(Int, e')] -> ST s (UArray i Double)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> ST s (UArray i e)unsafeAccumArrayUArrayDouble -> e' -> DoublefDoubleinitialValue(i, i)lu[(Int, e')]ies)instanceIArrayUArray(StablePtra)where{-# INLINEbounds#-}bounds :: UArray i (StablePtr a) -> (i, i)bounds(UArrayl :: ilu :: iu__)=(il,iu){-# INLINEnumElements#-}numElements :: UArray i (StablePtr a) -> IntnumElements(UArray__n :: Intn_)=Intn{-# INLINEunsafeArray#-}unsafeArray :: (i, i) -> [(Int, StablePtr a)] -> UArray i (StablePtr a)unsafeArraylu :: (i, i)luies :: [(Int, StablePtr a)]ies=(forall s. ST s (UArray i (StablePtr a))) -> UArray i (StablePtr a)forall a. (forall s. ST s a) -> arunST((i, i)-> [(Int, StablePtr a)]-> StablePtr a-> ST s (UArray i (StablePtr a))forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>(i, i) -> [(Int, e)] -> e -> ST s (UArray i e)unsafeArrayUArray(i, i)lu[(Int, StablePtr a)]iesStablePtr aforall a. StablePtr anullStablePtr){-# INLINEunsafeAt#-}unsafeAt :: UArray i (StablePtr a) -> Int -> StablePtr aunsafeAt(UArray___arr# :: ByteArray#arr#)(I#i# :: Int#i#)=StablePtr# a -> StablePtr aforall a. StablePtr# a -> StablePtr aStablePtr(ByteArray# -> Int# -> StablePtr# aforall a. ByteArray# -> Int# -> StablePtr# aindexStablePtrArray#ByteArray#arr#Int#i#){-# INLINEunsafeReplace#-}unsafeReplace :: UArray i (StablePtr a)-> [(Int, StablePtr a)] -> UArray i (StablePtr a)unsafeReplacearr :: UArray i (StablePtr a)arries :: [(Int, StablePtr a)]ies=(forall s. ST s (UArray i (StablePtr a))) -> UArray i (StablePtr a)forall a. (forall s. ST s a) -> arunST(UArray i (StablePtr a)-> [(Int, StablePtr a)] -> ST s (UArray i (StablePtr a))forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>UArray i e -> [(Int, e)] -> ST s (UArray i e)unsafeReplaceUArrayUArray i (StablePtr a)arr[(Int, StablePtr a)]ies){-# INLINEunsafeAccum#-}unsafeAccum :: (StablePtr a -> e' -> StablePtr a)-> UArray i (StablePtr a) -> [(Int, e')] -> UArray i (StablePtr a)unsafeAccumf :: StablePtr a -> e' -> StablePtr afarr :: UArray i (StablePtr a)arries :: [(Int, e')]ies=(forall s. ST s (UArray i (StablePtr a))) -> UArray i (StablePtr a)forall a. (forall s. ST s a) -> arunST((StablePtr a -> e' -> StablePtr a)-> UArray i (StablePtr a)-> [(Int, e')]-> ST s (UArray i (StablePtr a))forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> UArray i e -> [(Int, e')] -> ST s (UArray i e)unsafeAccumUArrayStablePtr a -> e' -> StablePtr afUArray i (StablePtr a)arr[(Int, e')]ies){-# INLINEunsafeAccumArray#-}unsafeAccumArray :: (StablePtr a -> e' -> StablePtr a)-> StablePtr a -> (i, i) -> [(Int, e')] -> UArray i (StablePtr a)unsafeAccumArrayf :: StablePtr a -> e' -> StablePtr afinitialValue :: StablePtr ainitialValuelu :: (i, i)luies :: [(Int, e')]ies=(forall s. ST s (UArray i (StablePtr a))) -> UArray i (StablePtr a)forall a. (forall s. ST s a) -> arunST((StablePtr a -> e' -> StablePtr a)-> StablePtr a-> (i, i)-> [(Int, e')]-> ST s (UArray i (StablePtr a))forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> ST s (UArray i e)unsafeAccumArrayUArrayStablePtr a -> e' -> StablePtr afStablePtr ainitialValue(i, i)lu[(Int, e')]ies)-- bogus StablePtr value for initialising a UArray of StablePtr.nullStablePtr::StablePtranullStablePtr :: StablePtr anullStablePtr=StablePtr# a -> StablePtr aforall a. StablePtr# a -> StablePtr aStablePtr(Int# -> StablePtr# aunsafeCoerce#0#)instanceIArrayUArrayInt8where{-# INLINEbounds#-}bounds :: UArray i Int8 -> (i, i)bounds(UArrayl :: ilu :: iu__)=(il,iu){-# INLINEnumElements#-}numElements :: UArray i Int8 -> IntnumElements(UArray__n :: Intn_)=Intn{-# INLINEunsafeArray#-}unsafeArray :: (i, i) -> [(Int, Int8)] -> UArray i Int8unsafeArraylu :: (i, i)luies :: [(Int, Int8)]ies=(forall s. ST s (UArray i Int8)) -> UArray i Int8forall a. (forall s. ST s a) -> arunST((i, i) -> [(Int, Int8)] -> Int8 -> ST s (UArray i Int8)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>(i, i) -> [(Int, e)] -> e -> ST s (UArray i e)unsafeArrayUArray(i, i)lu[(Int, Int8)]ies0){-# INLINEunsafeAt#-}unsafeAt :: UArray i Int8 -> Int -> Int8unsafeAt(UArray___arr# :: ByteArray#arr#)(I#i# :: Int#i#)=Int# -> Int8I8#(ByteArray# -> Int# -> Int#indexInt8Array#ByteArray#arr#Int#i#){-# INLINEunsafeReplace#-}unsafeReplace :: UArray i Int8 -> [(Int, Int8)] -> UArray i Int8unsafeReplacearr :: UArray i Int8arries :: [(Int, Int8)]ies=(forall s. ST s (UArray i Int8)) -> UArray i Int8forall a. (forall s. ST s a) -> arunST(UArray i Int8 -> [(Int, Int8)] -> ST s (UArray i Int8)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>UArray i e -> [(Int, e)] -> ST s (UArray i e)unsafeReplaceUArrayUArray i Int8arr[(Int, Int8)]ies){-# INLINEunsafeAccum#-}unsafeAccum :: (Int8 -> e' -> Int8)-> UArray i Int8 -> [(Int, e')] -> UArray i Int8unsafeAccumf :: Int8 -> e' -> Int8farr :: UArray i Int8arries :: [(Int, e')]ies=(forall s. ST s (UArray i Int8)) -> UArray i Int8forall a. (forall s. ST s a) -> arunST((Int8 -> e' -> Int8)-> UArray i Int8 -> [(Int, e')] -> ST s (UArray i Int8)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> UArray i e -> [(Int, e')] -> ST s (UArray i e)unsafeAccumUArrayInt8 -> e' -> Int8fUArray i Int8arr[(Int, e')]ies){-# INLINEunsafeAccumArray#-}unsafeAccumArray :: (Int8 -> e' -> Int8)-> Int8 -> (i, i) -> [(Int, e')] -> UArray i Int8unsafeAccumArrayf :: Int8 -> e' -> Int8finitialValue :: Int8initialValuelu :: (i, i)luies :: [(Int, e')]ies=(forall s. ST s (UArray i Int8)) -> UArray i Int8forall a. (forall s. ST s a) -> arunST((Int8 -> e' -> Int8)-> Int8 -> (i, i) -> [(Int, e')] -> ST s (UArray i Int8)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> ST s (UArray i e)unsafeAccumArrayUArrayInt8 -> e' -> Int8fInt8initialValue(i, i)lu[(Int, e')]ies)instanceIArrayUArrayInt16where{-# INLINEbounds#-}bounds :: UArray i Int16 -> (i, i)bounds(UArrayl :: ilu :: iu__)=(il,iu){-# INLINEnumElements#-}numElements :: UArray i Int16 -> IntnumElements(UArray__n :: Intn_)=Intn{-# INLINEunsafeArray#-}unsafeArray :: (i, i) -> [(Int, Int16)] -> UArray i Int16unsafeArraylu :: (i, i)luies :: [(Int, Int16)]ies=(forall s. ST s (UArray i Int16)) -> UArray i Int16forall a. (forall s. ST s a) -> arunST((i, i) -> [(Int, Int16)] -> Int16 -> ST s (UArray i Int16)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>(i, i) -> [(Int, e)] -> e -> ST s (UArray i e)unsafeArrayUArray(i, i)lu[(Int, Int16)]ies0){-# INLINEunsafeAt#-}unsafeAt :: UArray i Int16 -> Int -> Int16unsafeAt(UArray___arr# :: ByteArray#arr#)(I#i# :: Int#i#)=Int# -> Int16I16#(ByteArray# -> Int# -> Int#indexInt16Array#ByteArray#arr#Int#i#){-# INLINEunsafeReplace#-}unsafeReplace :: UArray i Int16 -> [(Int, Int16)] -> UArray i Int16unsafeReplacearr :: UArray i Int16arries :: [(Int, Int16)]ies=(forall s. ST s (UArray i Int16)) -> UArray i Int16forall a. (forall s. ST s a) -> arunST(UArray i Int16 -> [(Int, Int16)] -> ST s (UArray i Int16)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>UArray i e -> [(Int, e)] -> ST s (UArray i e)unsafeReplaceUArrayUArray i Int16arr[(Int, Int16)]ies){-# INLINEunsafeAccum#-}unsafeAccum :: (Int16 -> e' -> Int16)-> UArray i Int16 -> [(Int, e')] -> UArray i Int16unsafeAccumf :: Int16 -> e' -> Int16farr :: UArray i Int16arries :: [(Int, e')]ies=(forall s. ST s (UArray i Int16)) -> UArray i Int16forall a. (forall s. ST s a) -> arunST((Int16 -> e' -> Int16)-> UArray i Int16 -> [(Int, e')] -> ST s (UArray i Int16)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> UArray i e -> [(Int, e')] -> ST s (UArray i e)unsafeAccumUArrayInt16 -> e' -> Int16fUArray i Int16arr[(Int, e')]ies){-# INLINEunsafeAccumArray#-}unsafeAccumArray :: (Int16 -> e' -> Int16)-> Int16 -> (i, i) -> [(Int, e')] -> UArray i Int16unsafeAccumArrayf :: Int16 -> e' -> Int16finitialValue :: Int16initialValuelu :: (i, i)luies :: [(Int, e')]ies=(forall s. ST s (UArray i Int16)) -> UArray i Int16forall a. (forall s. ST s a) -> arunST((Int16 -> e' -> Int16)-> Int16 -> (i, i) -> [(Int, e')] -> ST s (UArray i Int16)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> ST s (UArray i e)unsafeAccumArrayUArrayInt16 -> e' -> Int16fInt16initialValue(i, i)lu[(Int, e')]ies)instanceIArrayUArrayInt32where{-# INLINEbounds#-}bounds :: UArray i Int32 -> (i, i)bounds(UArrayl :: ilu :: iu__)=(il,iu){-# INLINEnumElements#-}numElements :: UArray i Int32 -> IntnumElements(UArray__n :: Intn_)=Intn{-# INLINEunsafeArray#-}unsafeArray :: (i, i) -> [(Int, Int32)] -> UArray i Int32unsafeArraylu :: (i, i)luies :: [(Int, Int32)]ies=(forall s. ST s (UArray i Int32)) -> UArray i Int32forall a. (forall s. ST s a) -> arunST((i, i) -> [(Int, Int32)] -> Int32 -> ST s (UArray i Int32)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>(i, i) -> [(Int, e)] -> e -> ST s (UArray i e)unsafeArrayUArray(i, i)lu[(Int, Int32)]ies0){-# INLINEunsafeAt#-}unsafeAt :: UArray i Int32 -> Int -> Int32unsafeAt(UArray___arr# :: ByteArray#arr#)(I#i# :: Int#i#)=Int# -> Int32I32#(ByteArray# -> Int# -> Int#indexInt32Array#ByteArray#arr#Int#i#){-# INLINEunsafeReplace#-}unsafeReplace :: UArray i Int32 -> [(Int, Int32)] -> UArray i Int32unsafeReplacearr :: UArray i Int32arries :: [(Int, Int32)]ies=(forall s. ST s (UArray i Int32)) -> UArray i Int32forall a. (forall s. ST s a) -> arunST(UArray i Int32 -> [(Int, Int32)] -> ST s (UArray i Int32)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>UArray i e -> [(Int, e)] -> ST s (UArray i e)unsafeReplaceUArrayUArray i Int32arr[(Int, Int32)]ies){-# INLINEunsafeAccum#-}unsafeAccum :: (Int32 -> e' -> Int32)-> UArray i Int32 -> [(Int, e')] -> UArray i Int32unsafeAccumf :: Int32 -> e' -> Int32farr :: UArray i Int32arries :: [(Int, e')]ies=(forall s. ST s (UArray i Int32)) -> UArray i Int32forall a. (forall s. ST s a) -> arunST((Int32 -> e' -> Int32)-> UArray i Int32 -> [(Int, e')] -> ST s (UArray i Int32)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> UArray i e -> [(Int, e')] -> ST s (UArray i e)unsafeAccumUArrayInt32 -> e' -> Int32fUArray i Int32arr[(Int, e')]ies){-# INLINEunsafeAccumArray#-}unsafeAccumArray :: (Int32 -> e' -> Int32)-> Int32 -> (i, i) -> [(Int, e')] -> UArray i Int32unsafeAccumArrayf :: Int32 -> e' -> Int32finitialValue :: Int32initialValuelu :: (i, i)luies :: [(Int, e')]ies=(forall s. ST s (UArray i Int32)) -> UArray i Int32forall a. (forall s. ST s a) -> arunST((Int32 -> e' -> Int32)-> Int32 -> (i, i) -> [(Int, e')] -> ST s (UArray i Int32)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> ST s (UArray i e)unsafeAccumArrayUArrayInt32 -> e' -> Int32fInt32initialValue(i, i)lu[(Int, e')]ies)instanceIArrayUArrayInt64where{-# INLINEbounds#-}bounds :: UArray i Int64 -> (i, i)bounds(UArrayl :: ilu :: iu__)=(il,iu){-# INLINEnumElements#-}numElements :: UArray i Int64 -> IntnumElements(UArray__n :: Intn_)=Intn{-# INLINEunsafeArray#-}unsafeArray :: (i, i) -> [(Int, Int64)] -> UArray i Int64unsafeArraylu :: (i, i)luies :: [(Int, Int64)]ies=(forall s. ST s (UArray i Int64)) -> UArray i Int64forall a. (forall s. ST s a) -> arunST((i, i) -> [(Int, Int64)] -> Int64 -> ST s (UArray i Int64)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>(i, i) -> [(Int, e)] -> e -> ST s (UArray i e)unsafeArrayUArray(i, i)lu[(Int, Int64)]ies0){-# INLINEunsafeAt#-}unsafeAt :: UArray i Int64 -> Int -> Int64unsafeAt(UArray___arr# :: ByteArray#arr#)(I#i# :: Int#i#)=Int# -> Int64I64#(ByteArray# -> Int# -> Int#indexInt64Array#ByteArray#arr#Int#i#){-# INLINEunsafeReplace#-}unsafeReplace :: UArray i Int64 -> [(Int, Int64)] -> UArray i Int64unsafeReplacearr :: UArray i Int64arries :: [(Int, Int64)]ies=(forall s. ST s (UArray i Int64)) -> UArray i Int64forall a. (forall s. ST s a) -> arunST(UArray i Int64 -> [(Int, Int64)] -> ST s (UArray i Int64)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>UArray i e -> [(Int, e)] -> ST s (UArray i e)unsafeReplaceUArrayUArray i Int64arr[(Int, Int64)]ies){-# INLINEunsafeAccum#-}unsafeAccum :: (Int64 -> e' -> Int64)-> UArray i Int64 -> [(Int, e')] -> UArray i Int64unsafeAccumf :: Int64 -> e' -> Int64farr :: UArray i Int64arries :: [(Int, e')]ies=(forall s. ST s (UArray i Int64)) -> UArray i Int64forall a. (forall s. ST s a) -> arunST((Int64 -> e' -> Int64)-> UArray i Int64 -> [(Int, e')] -> ST s (UArray i Int64)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> UArray i e -> [(Int, e')] -> ST s (UArray i e)unsafeAccumUArrayInt64 -> e' -> Int64fUArray i Int64arr[(Int, e')]ies){-# INLINEunsafeAccumArray#-}unsafeAccumArray :: (Int64 -> e' -> Int64)-> Int64 -> (i, i) -> [(Int, e')] -> UArray i Int64unsafeAccumArrayf :: Int64 -> e' -> Int64finitialValue :: Int64initialValuelu :: (i, i)luies :: [(Int, e')]ies=(forall s. ST s (UArray i Int64)) -> UArray i Int64forall a. (forall s. ST s a) -> arunST((Int64 -> e' -> Int64)-> Int64 -> (i, i) -> [(Int, e')] -> ST s (UArray i Int64)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> ST s (UArray i e)unsafeAccumArrayUArrayInt64 -> e' -> Int64fInt64initialValue(i, i)lu[(Int, e')]ies)instanceIArrayUArrayWord8where{-# INLINEbounds#-}bounds :: UArray i Word8 -> (i, i)bounds(UArrayl :: ilu :: iu__)=(il,iu){-# INLINEnumElements#-}numElements :: UArray i Word8 -> IntnumElements(UArray__n :: Intn_)=Intn{-# INLINEunsafeArray#-}unsafeArray :: (i, i) -> [(Int, Word8)] -> UArray i Word8unsafeArraylu :: (i, i)luies :: [(Int, Word8)]ies=(forall s. ST s (UArray i Word8)) -> UArray i Word8forall a. (forall s. ST s a) -> arunST((i, i) -> [(Int, Word8)] -> Word8 -> ST s (UArray i Word8)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>(i, i) -> [(Int, e)] -> e -> ST s (UArray i e)unsafeArrayUArray(i, i)lu[(Int, Word8)]ies0){-# INLINEunsafeAt#-}unsafeAt :: UArray i Word8 -> Int -> Word8unsafeAt(UArray___arr# :: ByteArray#arr#)(I#i# :: Int#i#)=Word# -> Word8W8#(ByteArray# -> Int# -> Word#indexWord8Array#ByteArray#arr#Int#i#){-# INLINEunsafeReplace#-}unsafeReplace :: UArray i Word8 -> [(Int, Word8)] -> UArray i Word8unsafeReplacearr :: UArray i Word8arries :: [(Int, Word8)]ies=(forall s. ST s (UArray i Word8)) -> UArray i Word8forall a. (forall s. ST s a) -> arunST(UArray i Word8 -> [(Int, Word8)] -> ST s (UArray i Word8)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>UArray i e -> [(Int, e)] -> ST s (UArray i e)unsafeReplaceUArrayUArray i Word8arr[(Int, Word8)]ies){-# INLINEunsafeAccum#-}unsafeAccum :: (Word8 -> e' -> Word8)-> UArray i Word8 -> [(Int, e')] -> UArray i Word8unsafeAccumf :: Word8 -> e' -> Word8farr :: UArray i Word8arries :: [(Int, e')]ies=(forall s. ST s (UArray i Word8)) -> UArray i Word8forall a. (forall s. ST s a) -> arunST((Word8 -> e' -> Word8)-> UArray i Word8 -> [(Int, e')] -> ST s (UArray i Word8)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> UArray i e -> [(Int, e')] -> ST s (UArray i e)unsafeAccumUArrayWord8 -> e' -> Word8fUArray i Word8arr[(Int, e')]ies){-# INLINEunsafeAccumArray#-}unsafeAccumArray :: (Word8 -> e' -> Word8)-> Word8 -> (i, i) -> [(Int, e')] -> UArray i Word8unsafeAccumArrayf :: Word8 -> e' -> Word8finitialValue :: Word8initialValuelu :: (i, i)luies :: [(Int, e')]ies=(forall s. ST s (UArray i Word8)) -> UArray i Word8forall a. (forall s. ST s a) -> arunST((Word8 -> e' -> Word8)-> Word8 -> (i, i) -> [(Int, e')] -> ST s (UArray i Word8)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> ST s (UArray i e)unsafeAccumArrayUArrayWord8 -> e' -> Word8fWord8initialValue(i, i)lu[(Int, e')]ies)instanceIArrayUArrayWord16where{-# INLINEbounds#-}bounds :: UArray i Word16 -> (i, i)bounds(UArrayl :: ilu :: iu__)=(il,iu){-# INLINEnumElements#-}numElements :: UArray i Word16 -> IntnumElements(UArray__n :: Intn_)=Intn{-# INLINEunsafeArray#-}unsafeArray :: (i, i) -> [(Int, Word16)] -> UArray i Word16unsafeArraylu :: (i, i)luies :: [(Int, Word16)]ies=(forall s. ST s (UArray i Word16)) -> UArray i Word16forall a. (forall s. ST s a) -> arunST((i, i) -> [(Int, Word16)] -> Word16 -> ST s (UArray i Word16)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>(i, i) -> [(Int, e)] -> e -> ST s (UArray i e)unsafeArrayUArray(i, i)lu[(Int, Word16)]ies0){-# INLINEunsafeAt#-}unsafeAt :: UArray i Word16 -> Int -> Word16unsafeAt(UArray___arr# :: ByteArray#arr#)(I#i# :: Int#i#)=Word# -> Word16W16#(ByteArray# -> Int# -> Word#indexWord16Array#ByteArray#arr#Int#i#){-# INLINEunsafeReplace#-}unsafeReplace :: UArray i Word16 -> [(Int, Word16)] -> UArray i Word16unsafeReplacearr :: UArray i Word16arries :: [(Int, Word16)]ies=(forall s. ST s (UArray i Word16)) -> UArray i Word16forall a. (forall s. ST s a) -> arunST(UArray i Word16 -> [(Int, Word16)] -> ST s (UArray i Word16)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>UArray i e -> [(Int, e)] -> ST s (UArray i e)unsafeReplaceUArrayUArray i Word16arr[(Int, Word16)]ies){-# INLINEunsafeAccum#-}unsafeAccum :: (Word16 -> e' -> Word16)-> UArray i Word16 -> [(Int, e')] -> UArray i Word16unsafeAccumf :: Word16 -> e' -> Word16farr :: UArray i Word16arries :: [(Int, e')]ies=(forall s. ST s (UArray i Word16)) -> UArray i Word16forall a. (forall s. ST s a) -> arunST((Word16 -> e' -> Word16)-> UArray i Word16 -> [(Int, e')] -> ST s (UArray i Word16)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> UArray i e -> [(Int, e')] -> ST s (UArray i e)unsafeAccumUArrayWord16 -> e' -> Word16fUArray i Word16arr[(Int, e')]ies){-# INLINEunsafeAccumArray#-}unsafeAccumArray :: (Word16 -> e' -> Word16)-> Word16 -> (i, i) -> [(Int, e')] -> UArray i Word16unsafeAccumArrayf :: Word16 -> e' -> Word16finitialValue :: Word16initialValuelu :: (i, i)luies :: [(Int, e')]ies=(forall s. ST s (UArray i Word16)) -> UArray i Word16forall a. (forall s. ST s a) -> arunST((Word16 -> e' -> Word16)-> Word16 -> (i, i) -> [(Int, e')] -> ST s (UArray i Word16)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> ST s (UArray i e)unsafeAccumArrayUArrayWord16 -> e' -> Word16fWord16initialValue(i, i)lu[(Int, e')]ies)instanceIArrayUArrayWord32where{-# INLINEbounds#-}bounds :: UArray i Word32 -> (i, i)bounds(UArrayl :: ilu :: iu__)=(il,iu){-# INLINEnumElements#-}numElements :: UArray i Word32 -> IntnumElements(UArray__n :: Intn_)=Intn{-# INLINEunsafeArray#-}unsafeArray :: (i, i) -> [(Int, Word32)] -> UArray i Word32unsafeArraylu :: (i, i)luies :: [(Int, Word32)]ies=(forall s. ST s (UArray i Word32)) -> UArray i Word32forall a. (forall s. ST s a) -> arunST((i, i) -> [(Int, Word32)] -> Word32 -> ST s (UArray i Word32)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>(i, i) -> [(Int, e)] -> e -> ST s (UArray i e)unsafeArrayUArray(i, i)lu[(Int, Word32)]ies0){-# INLINEunsafeAt#-}unsafeAt :: UArray i Word32 -> Int -> Word32unsafeAt(UArray___arr# :: ByteArray#arr#)(I#i# :: Int#i#)=Word# -> Word32W32#(ByteArray# -> Int# -> Word#indexWord32Array#ByteArray#arr#Int#i#){-# INLINEunsafeReplace#-}unsafeReplace :: UArray i Word32 -> [(Int, Word32)] -> UArray i Word32unsafeReplacearr :: UArray i Word32arries :: [(Int, Word32)]ies=(forall s. ST s (UArray i Word32)) -> UArray i Word32forall a. (forall s. ST s a) -> arunST(UArray i Word32 -> [(Int, Word32)] -> ST s (UArray i Word32)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>UArray i e -> [(Int, e)] -> ST s (UArray i e)unsafeReplaceUArrayUArray i Word32arr[(Int, Word32)]ies){-# INLINEunsafeAccum#-}unsafeAccum :: (Word32 -> e' -> Word32)-> UArray i Word32 -> [(Int, e')] -> UArray i Word32unsafeAccumf :: Word32 -> e' -> Word32farr :: UArray i Word32arries :: [(Int, e')]ies=(forall s. ST s (UArray i Word32)) -> UArray i Word32forall a. (forall s. ST s a) -> arunST((Word32 -> e' -> Word32)-> UArray i Word32 -> [(Int, e')] -> ST s (UArray i Word32)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> UArray i e -> [(Int, e')] -> ST s (UArray i e)unsafeAccumUArrayWord32 -> e' -> Word32fUArray i Word32arr[(Int, e')]ies){-# INLINEunsafeAccumArray#-}unsafeAccumArray :: (Word32 -> e' -> Word32)-> Word32 -> (i, i) -> [(Int, e')] -> UArray i Word32unsafeAccumArrayf :: Word32 -> e' -> Word32finitialValue :: Word32initialValuelu :: (i, i)luies :: [(Int, e')]ies=(forall s. ST s (UArray i Word32)) -> UArray i Word32forall a. (forall s. ST s a) -> arunST((Word32 -> e' -> Word32)-> Word32 -> (i, i) -> [(Int, e')] -> ST s (UArray i Word32)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> ST s (UArray i e)unsafeAccumArrayUArrayWord32 -> e' -> Word32fWord32initialValue(i, i)lu[(Int, e')]ies)instanceIArrayUArrayWord64where{-# INLINEbounds#-}bounds :: UArray i Word64 -> (i, i)bounds(UArrayl :: ilu :: iu__)=(il,iu){-# INLINEnumElements#-}numElements :: UArray i Word64 -> IntnumElements(UArray__n :: Intn_)=Intn{-# INLINEunsafeArray#-}unsafeArray :: (i, i) -> [(Int, Word64)] -> UArray i Word64unsafeArraylu :: (i, i)luies :: [(Int, Word64)]ies=(forall s. ST s (UArray i Word64)) -> UArray i Word64forall a. (forall s. ST s a) -> arunST((i, i) -> [(Int, Word64)] -> Word64 -> ST s (UArray i Word64)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>(i, i) -> [(Int, e)] -> e -> ST s (UArray i e)unsafeArrayUArray(i, i)lu[(Int, Word64)]ies0){-# INLINEunsafeAt#-}unsafeAt :: UArray i Word64 -> Int -> Word64unsafeAt(UArray___arr# :: ByteArray#arr#)(I#i# :: Int#i#)=Word# -> Word64W64#(ByteArray# -> Int# -> Word#indexWord64Array#ByteArray#arr#Int#i#){-# INLINEunsafeReplace#-}unsafeReplace :: UArray i Word64 -> [(Int, Word64)] -> UArray i Word64unsafeReplacearr :: UArray i Word64arries :: [(Int, Word64)]ies=(forall s. ST s (UArray i Word64)) -> UArray i Word64forall a. (forall s. ST s a) -> arunST(UArray i Word64 -> [(Int, Word64)] -> ST s (UArray i Word64)forall s e i.(MArray (STUArray s) e (ST s), Ix i) =>UArray i e -> [(Int, e)] -> ST s (UArray i e)unsafeReplaceUArrayUArray i Word64arr[(Int, Word64)]ies){-# INLINEunsafeAccum#-}unsafeAccum :: (Word64 -> e' -> Word64)-> UArray i Word64 -> [(Int, e')] -> UArray i Word64unsafeAccumf :: Word64 -> e' -> Word64farr :: UArray i Word64arries :: [(Int, e')]ies=(forall s. ST s (UArray i Word64)) -> UArray i Word64forall a. (forall s. ST s a) -> arunST((Word64 -> e' -> Word64)-> UArray i Word64 -> [(Int, e')] -> ST s (UArray i Word64)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> UArray i e -> [(Int, e')] -> ST s (UArray i e)unsafeAccumUArrayWord64 -> e' -> Word64fUArray i Word64arr[(Int, e')]ies){-# INLINEunsafeAccumArray#-}unsafeAccumArray :: (Word64 -> e' -> Word64)-> Word64 -> (i, i) -> [(Int, e')] -> UArray i Word64unsafeAccumArrayf :: Word64 -> e' -> Word64finitialValue :: Word64initialValuelu :: (i, i)luies :: [(Int, e')]ies=(forall s. ST s (UArray i Word64)) -> UArray i Word64forall a. (forall s. ST s a) -> arunST((Word64 -> e' -> Word64)-> Word64 -> (i, i) -> [(Int, e')] -> ST s (UArray i Word64)forall s e i e'.(MArray (STUArray s) e (ST s), Ix i) =>(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> ST s (UArray i e)unsafeAccumArrayUArrayWord64 -> e' -> Word64fWord64initialValue(i, i)lu[(Int, e')]ies)instance(Ixix,Eqe,IArrayUArraye)=>Eq(UArrayixe)where== :: UArray ix e -> UArray ix e -> Bool(==)=UArray ix e -> UArray ix e -> Boolforall e i.(IArray UArray e, Ix i, Eq e) =>UArray i e -> UArray i e -> BooleqUArrayinstance(Ixix,Orde,IArrayUArraye)=>Ord(UArrayixe)wherecompare :: UArray ix e -> UArray ix e -> Orderingcompare=UArray ix e -> UArray ix e -> Orderingforall e i.(IArray UArray e, Ix i, Ord e) =>UArray i e -> UArray i e -> OrderingcmpUArrayinstance(Ixix,Showix,Showe,IArrayUArraye)=>Show(UArrayixe)whereshowsPrec :: Int -> UArray ix e -> [Char] -> [Char]showsPrec=Int -> UArray ix e -> [Char] -> [Char]forall (a :: * -> * -> *) e i.(IArray a e, Ix i, Show i, Show e) =>Int -> a i e -> [Char] -> [Char]showsIArrayinstance(Ixix,Readix,Reade,IArrayUArraye)=>Read(UArrayixe)wherereadPrec :: ReadPrec (UArray ix e)readPrec=ReadPrec (UArray ix e)forall (a :: * -> * -> *) e i.(IArray a e, Ix i, Read i, Read e) =>ReadPrec (a i e)readIArray------------------------------------------------------------------------------- Mutable arrays{-# NOINLINEarrEleBottom#-}arrEleBottom::aarrEleBottom :: aarrEleBottom=[Char] -> aforall a. HasCallStack => [Char] -> aerror"MArray: undefined array element"{-| Class of mutable array types.An array type has the form @(a i e)@ where @a@ is the array typeconstructor (kind @* -> * -> *@), @i@ is the index type (a member ofthe class 'Ix'), and @e@ is the element type.The @MArray@ class is parameterised over both @a@ and @e@ (so thatinstances specialised to certain element types can be defined, in thesame way as for 'IArray'), and also over the type of the monad, @m@,in which the mutable array will be manipulated.-}class(Monadm)=>MArrayaemwhere-- | Returns the bounds of the arraygetBounds::Ixi=>aie->m(i,i)-- | Returns the number of elements in the arraygetNumElements::Ixi=>aie->mInt-- | Builds a new array, with every element initialised to the supplied-- value.newArray::Ixi=>(i,i)->e->m(aie)-- | Builds a new array, with every element initialised to an-- undefined value. In a monadic context in which operations must-- be deterministic (e.g. the ST monad), the array elements are-- initialised to a fixed but undefined value, such as zero.newArray_::Ixi=>(i,i)->m(aie)-- | Builds a new array, with every element initialised to an undefined-- value.unsafeNewArray_::Ixi=>(i,i)->m(aie)unsafeRead::Ixi=>aie->Int->meunsafeWrite::Ixi=>aie->Int->e->m(){-# INLINEnewArray#-}-- The INLINE is crucial, because until we know at least which monad-- we are in, the code below allocates like crazy. So inline it,-- in the hope that the context will know the monad.newArray(l :: il,u :: iu)initialValue :: einitialValue=doletn :: Intn=(i, i) -> Intforall a. Ix a => (a, a) -> IntsafeRangeSize(il,iu)a i emarr<-(i, i) -> m (a i e)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> m (a i e)unsafeNewArray_(il,iu)[m ()] -> m ()forall (t :: * -> *) (m :: * -> *) a.(Foldable t, Monad m) =>t (m a) -> m ()sequence_[a i e -> Int -> e -> m ()forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> e -> m ()unsafeWritea i emarrIntieinitialValue|Inti<-[0..IntnInt -> Int -> Intforall a. Num a => a -> a -> a-1]]a i e -> m (a i e)forall (m :: * -> *) a. Monad m => a -> m areturna i emarr{-# INLINEunsafeNewArray_#-}unsafeNewArray_(l :: il,u :: iu)=(i, i) -> e -> m (a i e)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(il,iu)eforall a. aarrEleBottom{-# INLINEnewArray_#-}newArray_(l :: il,u :: iu)=(i, i) -> e -> m (a i e)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(il,iu)eforall a. aarrEleBottom-- newArray takes an initialiser which all elements of-- the newly created array are initialised to. unsafeNewArray_ takes-- no initialiser, it is assumed that the array is initialised with-- "undefined" values.-- why not omit unsafeNewArray_? Because in the unboxed array-- case we would like to omit the initialisation altogether if-- possible. We can't do this for boxed arrays, because the-- elements must all have valid values at all times in case of-- garbage collection.-- why not omit newArray? Because in the boxed case, we can omit the-- default initialisation with undefined values if we *do* know the-- initial value and it is constant for all elements.instanceMArrayIOArrayeIOwhere{-# INLINEgetBounds#-}getBounds :: IOArray i e -> IO (i, i)getBounds(IOArraymarr :: STArray RealWorld i emarr)=ST RealWorld (i, i) -> IO (i, i)forall a. ST RealWorld a -> IO astToIO(ST RealWorld (i, i) -> IO (i, i))-> ST RealWorld (i, i) -> IO (i, i)forall a b. (a -> b) -> a -> b$STArray RealWorld i e -> ST RealWorld (i, i)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> m (i, i)getBoundsSTArray RealWorld i emarr{-# INLINEgetNumElements#-}getNumElements :: IOArray i e -> IO IntgetNumElements(IOArraymarr :: STArray RealWorld i emarr)=ST RealWorld Int -> IO Intforall a. ST RealWorld a -> IO astToIO(ST RealWorld Int -> IO Int) -> ST RealWorld Int -> IO Intforall a b. (a -> b) -> a -> b$STArray RealWorld i e -> ST RealWorld Intforall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> m IntgetNumElementsSTArray RealWorld i emarrnewArray :: (i, i) -> e -> IO (IOArray i e)newArray=(i, i) -> e -> IO (IOArray i e)forall i e. Ix i => (i, i) -> e -> IO (IOArray i e)newIOArrayunsafeRead :: IOArray i e -> Int -> IO eunsafeRead=IOArray i e -> Int -> IO eforall i e. IOArray i e -> Int -> IO eunsafeReadIOArrayunsafeWrite :: IOArray i e -> Int -> e -> IO ()unsafeWrite=IOArray i e -> Int -> e -> IO ()forall i e. IOArray i e -> Int -> e -> IO ()unsafeWriteIOArray{-# INLINEnewListArray#-}-- | Constructs a mutable array from a list of initial elements.-- The list gives the elements of the array in ascending order-- beginning with the lowest index.newListArray::(MArrayaem,Ixi)=>(i,i)->[e]->m(aie)newListArray :: (i, i) -> [e] -> m (a i e)newListArray(l :: il,u :: iu)es :: [e]es=doa i emarr<-(i, i) -> m (a i e)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> m (a i e)newArray_(il,iu)letn :: Intn=(i, i) -> Intforall a. Ix a => (a, a) -> IntsafeRangeSize(il,iu)letfillFromList :: Int -> [e] -> m ()fillFromListi :: Intixs :: [e]xs|IntiInt -> Int -> Boolforall a. Eq a => a -> a -> Bool==Intn=() -> m ()forall (m :: * -> *) a. Monad m => a -> m areturn()|Boolotherwise=case[e]xsof[]->() -> m ()forall (m :: * -> *) a. Monad m => a -> m areturn()y :: ey:ys :: [e]ys->a i e -> Int -> e -> m ()forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> e -> m ()unsafeWritea i emarrIntieym () -> m () -> m ()forall (m :: * -> *) a b. Monad m => m a -> m b -> m b>>Int -> [e] -> m ()fillFromList(IntiInt -> Int -> Intforall a. Num a => a -> a -> a+1)[e]ysInt -> [e] -> m ()forall (m :: * -> *). MArray a e m => Int -> [e] -> m ()fillFromList0[e]esa i e -> m (a i e)forall (m :: * -> *) a. Monad m => a -> m areturna i emarr{-# INLINEreadArray#-}-- | Read an element from a mutable arrayreadArray::(MArrayaem,Ixi)=>aie->i->mereadArray :: a i e -> i -> m ereadArraymarr :: a i emarri :: ii=do(l :: il,u :: iu)<-a i e -> m (i, i)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> m (i, i)getBoundsa i emarrIntn<-a i e -> m Intforall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> m IntgetNumElementsa i emarra i e -> Int -> m eforall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> m eunsafeReada i emarr((i, i) -> Int -> i -> Intforall i. Ix i => (i, i) -> Int -> i -> IntsafeIndex(il,iu)Intnii){-# INLINEwriteArray#-}-- | Write an element in a mutable arraywriteArray::(MArrayaem,Ixi)=>aie->i->e->m()writeArray :: a i e -> i -> e -> m ()writeArraymarr :: a i emarri :: iie :: ee=do(l :: il,u :: iu)<-a i e -> m (i, i)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> m (i, i)getBoundsa i emarrIntn<-a i e -> m Intforall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> m IntgetNumElementsa i emarra i e -> Int -> e -> m ()forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> e -> m ()unsafeWritea i emarr((i, i) -> Int -> i -> Intforall i. Ix i => (i, i) -> Int -> i -> IntsafeIndex(il,iu)Intnii)ee{-# INLINEgetElems#-}-- | Return a list of all the elements of a mutable arraygetElems::(MArrayaem,Ixi)=>aie->m[e]getElems :: a i e -> m [e]getElemsmarr :: a i emarr=do(_l :: i_l,_u :: i_u)<-a i e -> m (i, i)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> m (i, i)getBoundsa i emarrIntn<-a i e -> m Intforall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> m IntgetNumElementsa i emarr[m e] -> m [e]forall (t :: * -> *) (m :: * -> *) a.(Traversable t, Monad m) =>t (m a) -> m (t a)sequence[a i e -> Int -> m eforall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> m eunsafeReada i emarrInti|Inti<-[0..IntnInt -> Int -> Intforall a. Num a => a -> a -> a-1]]{-# INLINEgetAssocs#-}-- | Return a list of all the associations of a mutable array, in-- index order.getAssocs::(MArrayaem,Ixi)=>aie->m[(i,e)]getAssocs :: a i e -> m [(i, e)]getAssocsmarr :: a i emarr=do(l :: il,u :: iu)<-a i e -> m (i, i)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> m (i, i)getBoundsa i emarrIntn<-a i e -> m Intforall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> m IntgetNumElementsa i emarr[m (i, e)] -> m [(i, e)]forall (t :: * -> *) (m :: * -> *) a.(Traversable t, Monad m) =>t (m a) -> m (t a)sequence[doee<-a i e -> Int -> m eforall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> m eunsafeReada i emarr((i, i) -> Int -> i -> Intforall i. Ix i => (i, i) -> Int -> i -> IntsafeIndex(il,iu)Intnii);(i, e) -> m (i, e)forall (m :: * -> *) a. Monad m => a -> m areturn(ii,ee)|ii<-(i, i) -> [i]forall a. Ix a => (a, a) -> [a]range(il,iu)]{-# INLINEmapArray#-}-- | Constructs a new array derived from the original array by applying a-- function to each of the elements.mapArray::(MArrayae'm,MArrayaem,Ixi)=>(e'->e)->aie'->m(aie)mapArray :: (e' -> e) -> a i e' -> m (a i e)mapArrayf :: e' -> efmarr :: a i e'marr=do(l :: il,u :: iu)<-a i e' -> m (i, i)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> m (i, i)getBoundsa i e'marrIntn<-a i e' -> m Intforall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> m IntgetNumElementsa i e'marra i emarr'<-(i, i) -> m (a i e)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> m (a i e)newArray_(il,iu)[m ()] -> m ()forall (t :: * -> *) (m :: * -> *) a.(Foldable t, Monad m) =>t (m a) -> m ()sequence_[doe'e<-a i e' -> Int -> m e'forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> m eunsafeReada i e'marrIntia i e -> Int -> e -> m ()forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> e -> m ()unsafeWritea i emarr'Inti(e' -> efe'e)|Inti<-[0..IntnInt -> Int -> Intforall a. Num a => a -> a -> a-1]]a i e -> m (a i e)forall (m :: * -> *) a. Monad m => a -> m areturna i emarr'{-# INLINEmapIndices#-}-- | Constructs a new array derived from the original array by applying a-- function to each of the indices.mapIndices::(MArrayaem,Ixi,Ixj)=>(i,i)->(i->j)->aje->m(aie)mapIndices :: (i, i) -> (i -> j) -> a j e -> m (a i e)mapIndices(l' :: il',u' :: iu')f :: i -> jfmarr :: a j emarr=doa i emarr'<-(i, i) -> m (a i e)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> m (a i e)newArray_(il',iu')Intn'<-a i e -> m Intforall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> m IntgetNumElementsa i emarr'[m ()] -> m ()forall (t :: * -> *) (m :: * -> *) a.(Foldable t, Monad m) =>t (m a) -> m ()sequence_[doee<-a j e -> j -> m eforall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> i -> m ereadArraya j emarr(i -> jfii')a i e -> Int -> e -> m ()forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> e -> m ()unsafeWritea i emarr'((i, i) -> Int -> i -> Intforall i. Ix i => (i, i) -> Int -> i -> IntsafeIndex(il',iu')Intn'ii')ee|ii'<-(i, i) -> [i]forall a. Ix a => (a, a) -> [a]range(il',iu')]a i e -> m (a i e)forall (m :: * -> *) a. Monad m => a -> m areturna i emarr'------------------------------------------------------------------------------- Polymorphic non-strict mutable arrays (ST monad)instanceMArray(STArrays)e(STs)where{-# INLINEgetBounds#-}getBounds :: STArray s i e -> ST s (i, i)getBoundsarr :: STArray s i earr=(i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn((i, i) -> ST s (i, i)) -> (i, i) -> ST s (i, i)forall a b. (a -> b) -> a -> b$!STArray s i e -> (i, i)forall s i e. STArray s i e -> (i, i)ArrST.boundsSTArraySTArray s i earr{-# INLINEgetNumElements#-}getNumElements :: STArray s i e -> ST s IntgetNumElementsarr :: STArray s i earr=Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturn(Int -> ST s Int) -> Int -> ST s Intforall a b. (a -> b) -> a -> b$!STArray s i e -> Intforall s i e. STArray s i e -> IntArrST.numElementsSTArraySTArray s i earr{-# INLINEnewArray#-}newArray :: (i, i) -> e -> ST s (STArray s i e)newArray=(i, i) -> e -> ST s (STArray s i e)forall i e s. Ix i => (i, i) -> e -> ST s (STArray s i e)ArrST.newSTArray{-# INLINEunsafeRead#-}unsafeRead :: STArray s i e -> Int -> ST s eunsafeRead=STArray s i e -> Int -> ST s eforall s i e. STArray s i e -> Int -> ST s eArrST.unsafeReadSTArray{-# INLINEunsafeWrite#-}unsafeWrite :: STArray s i e -> Int -> e -> ST s ()unsafeWrite=STArray s i e -> Int -> e -> ST s ()forall s i e. STArray s i e -> Int -> e -> ST s ()ArrST.unsafeWriteSTArrayinstanceMArray(STArrays)e(Lazy.STs)where{-# INLINEgetBounds#-}getBounds :: STArray s i e -> ST s (i, i)getBoundsarr :: STArray s i earr=ST s (i, i) -> ST s (i, i)forall s a. ST s a -> ST s astrictToLazyST((i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn((i, i) -> ST s (i, i)) -> (i, i) -> ST s (i, i)forall a b. (a -> b) -> a -> b$!STArray s i e -> (i, i)forall s i e. STArray s i e -> (i, i)ArrST.boundsSTArraySTArray s i earr){-# INLINEgetNumElements#-}getNumElements :: STArray s i e -> ST s IntgetNumElementsarr :: STArray s i earr=ST s Int -> ST s Intforall s a. ST s a -> ST s astrictToLazyST(Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturn(Int -> ST s Int) -> Int -> ST s Intforall a b. (a -> b) -> a -> b$!STArray s i e -> Intforall s i e. STArray s i e -> IntArrST.numElementsSTArraySTArray s i earr){-# INLINEnewArray#-}newArray :: (i, i) -> e -> ST s (STArray s i e)newArray(l :: il,u :: iu)e :: ee=ST s (STArray s i e) -> ST s (STArray s i e)forall s a. ST s a -> ST s astrictToLazyST((i, i) -> e -> ST s (STArray s i e)forall i e s. Ix i => (i, i) -> e -> ST s (STArray s i e)ArrST.newSTArray(il,iu)ee){-# INLINEunsafeRead#-}unsafeRead :: STArray s i e -> Int -> ST s eunsafeReadarr :: STArray s i earri :: Inti=ST s e -> ST s eforall s a. ST s a -> ST s astrictToLazyST(STArray s i e -> Int -> ST s eforall s i e. STArray s i e -> Int -> ST s eArrST.unsafeReadSTArraySTArray s i earrInti){-# INLINEunsafeWrite#-}unsafeWrite :: STArray s i e -> Int -> e -> ST s ()unsafeWritearr :: STArray s i earri :: Intie :: ee=ST s () -> ST s ()forall s a. ST s a -> ST s astrictToLazyST(STArray s i e -> Int -> e -> ST s ()forall s i e. STArray s i e -> Int -> e -> ST s ()ArrST.unsafeWriteSTArraySTArray s i earrIntiee)------------------------------------------------------------------------------- Flat unboxed mutable arrays (ST monad)-- | A mutable array with unboxed elements, that can be manipulated in-- the 'ST' monad. The type arguments are as follows:---- * @s@: the state variable argument for the 'ST' type---- * @i@: the index type of the array (should be an instance of @Ix@)---- * @e@: the element type of the array. Only certain element types-- are supported.---- An 'STUArray' will generally be more efficient (in terms of both time-- and space) than the equivalent boxed version ('STArray') with the same-- element type. However, 'STUArray' is strict in its elements - so-- don\'t use 'STUArray' if you require the non-strictness that-- 'STArray' provides.dataSTUArraysie=STUArray!i!i!Int(MutableByteArray#s)-- The "ST" parameter must be nominal for the safety of the ST trick.-- The other parameters have class constraints. See also #9220.typeroleSTUArraynominalnominalnominalinstanceEq(STUArraysie)whereSTUArray___arr1# :: MutableByteArray# sarr1#== :: STUArray s i e -> STUArray s i e -> Bool==STUArray___arr2# :: MutableByteArray# sarr2#=Int# -> BoolisTrue#(MutableByteArray# s -> MutableByteArray# s -> Int#forall d. MutableByteArray# d -> MutableByteArray# d -> Int#sameMutableByteArray#MutableByteArray# sarr1#MutableByteArray# sarr2#){-# INLINEunsafeNewArraySTUArray_#-}unsafeNewArraySTUArray_::Ixi=>(i,i)->(Int#->Int#)->STs(STUArraysie)unsafeNewArraySTUArray_ :: (i, i) -> (Int# -> Int#) -> ST s (STUArray s i e)unsafeNewArraySTUArray_(l :: il,u :: iu)elemsToBytes :: Int# -> Int#elemsToBytes=case(i, i) -> Intforall a. Ix a => (a, a) -> IntrangeSize(il,iu)ofn :: Intn@(I#n# :: Int#n#)->STRep s (STUArray s i e) -> ST s (STUArray s i e)forall s a. STRep s a -> ST s aST(STRep s (STUArray s i e) -> ST s (STUArray s i e))-> STRep s (STUArray s i e) -> ST s (STUArray s i e)forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseInt# -> State# s -> (# State# s, MutableByteArray# s #)forall d. Int# -> State# d -> (# State# d, MutableByteArray# d #)newByteArray#(Int# -> Int#elemsToBytesInt#n#)State# ss1#of(#s2# :: State# ss2#,marr# :: MutableByteArray# smarr##)->(#State# ss2#,i -> i -> Int -> MutableByteArray# s -> STUArray s i eforall s i e.i -> i -> Int -> MutableByteArray# s -> STUArray s i eSTUArrayiliuIntnMutableByteArray# smarr##)instanceMArray(STUArrays)Bool(STs)where{-# INLINEgetBounds#-}getBounds :: STUArray s i Bool -> ST s (i, i)getBounds(STUArrayl :: ilu :: iu__)=(i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn(il,iu){-# INLINEgetNumElements#-}getNumElements :: STUArray s i Bool -> ST s IntgetNumElements(STUArray__n :: Intn_)=Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturnIntn{-# INLINEnewArray#-}newArray :: (i, i) -> Bool -> ST s (STUArray s i Bool)newArray(l :: il,u :: iu)initialValue :: BoolinitialValue=STRep s (STUArray s i Bool) -> ST s (STUArray s i Bool)forall s a. STRep s a -> ST s aST(STRep s (STUArray s i Bool) -> ST s (STUArray s i Bool))-> STRep s (STUArray s i Bool) -> ST s (STUArray s i Bool)forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->case(i, i) -> Intforall a. Ix a => (a, a) -> IntsafeRangeSize(il,iu)of{n :: Intn@(I#n# :: Int#n#)->caseInt# -> Int#bOOL_SCALEInt#n#of{nbytes# :: Int#nbytes#->caseInt# -> State# s -> (# State# s, MutableByteArray# s #)forall d. Int# -> State# d -> (# State# d, MutableByteArray# d #)newByteArray#Int#nbytes#State# ss1#of{(#s2# :: State# ss2#,marr# :: MutableByteArray# smarr##)->caseMutableByteArray# s -> Int# -> Int# -> Int# -> State# s -> State# sforall d.MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# dsetByteArray#MutableByteArray# smarr#0#Int#nbytes#Int#e#State# ss2#of{s3# :: State# ss3#->(#State# ss3#,i -> i -> Int -> MutableByteArray# s -> STUArray s i Boolforall s i e.i -> i -> Int -> MutableByteArray# s -> STUArray s i eSTUArrayiliuIntnMutableByteArray# smarr##)}}}}where!(I#e# :: Int#e#)=ifBoolinitialValuethen0xffelse0x0{-# INLINEunsafeNewArray_#-}unsafeNewArray_ :: (i, i) -> ST s (STUArray s i Bool)unsafeNewArray_(l :: il,u :: iu)=(i, i) -> (Int# -> Int#) -> ST s (STUArray s i Bool)forall i s e.Ix i =>(i, i) -> (Int# -> Int#) -> ST s (STUArray s i e)unsafeNewArraySTUArray_(il,iu)Int# -> Int#bOOL_SCALE{-# INLINEnewArray_#-}newArray_ :: (i, i) -> ST s (STUArray s i Bool)newArray_arrBounds :: (i, i)arrBounds=(i, i) -> Bool -> ST s (STUArray s i Bool)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(i, i)arrBoundsBoolFalse{-# INLINEunsafeRead#-}unsafeRead :: STUArray s i Bool -> Int -> ST s BoolunsafeRead(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)=STRep s Bool -> ST s Boolforall s a. STRep s a -> ST s aST(STRep s Bool -> ST s Bool) -> STRep s Bool -> ST s Boolforall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)forall d.MutableByteArray# d -> Int# -> State# d -> (# State# d, Word# #)readWordArray#MutableByteArray# smarr#(Int# -> Int#bOOL_INDEXInt#i#)State# ss1#of{(#s2# :: State# ss2#,e# :: Word#e##)->(#State# ss2#,Int# -> BoolisTrue#((Word#e#Word# -> Word# -> Word#`and#`Int# -> Word#bOOL_BITInt#i#)Word# -> Word# -> Int#`neWord#`Int# -> Word#int2Word#0#)::Bool#)}{-# INLINEunsafeWrite#-}unsafeWrite :: STUArray s i Bool -> Int -> Bool -> ST s ()unsafeWrite(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)e :: Boole=STRep s () -> ST s ()forall s a. STRep s a -> ST s aST(STRep s () -> ST s ()) -> STRep s () -> ST s ()forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseInt# -> Int#bOOL_INDEXInt#i#of{j# :: Int#j#->caseMutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)forall d.MutableByteArray# d -> Int# -> State# d -> (# State# d, Word# #)readWordArray#MutableByteArray# smarr#Int#j#State# ss1#of{(#s2# :: State# ss2#,old# :: Word#old##)->caseifBoolethenWord#old#Word# -> Word# -> Word#`or#`Int# -> Word#bOOL_BITInt#i#elseWord#old#Word# -> Word# -> Word#`and#`Int# -> Word#bOOL_NOT_BITInt#i#of{e# :: Word#e#->caseMutableByteArray# s -> Int# -> Word# -> State# s -> State# sforall d.MutableByteArray# d -> Int# -> Word# -> State# d -> State# dwriteWordArray#MutableByteArray# smarr#Int#j#Word#e#State# ss2#of{s3# :: State# ss3#->(#State# ss3#,()#)}}}}instanceMArray(STUArrays)Char(STs)where{-# INLINEgetBounds#-}getBounds :: STUArray s i Char -> ST s (i, i)getBounds(STUArrayl :: ilu :: iu__)=(i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn(il,iu){-# INLINEgetNumElements#-}getNumElements :: STUArray s i Char -> ST s IntgetNumElements(STUArray__n :: Intn_)=Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturnIntn{-# INLINEunsafeNewArray_#-}unsafeNewArray_ :: (i, i) -> ST s (STUArray s i Char)unsafeNewArray_(l :: il,u :: iu)=(i, i) -> (Int# -> Int#) -> ST s (STUArray s i Char)forall i s e.Ix i =>(i, i) -> (Int# -> Int#) -> ST s (STUArray s i e)unsafeNewArraySTUArray_(il,iu)(Int# -> Int# -> Int#safe_scale4#){-# INLINEnewArray_#-}newArray_ :: (i, i) -> ST s (STUArray s i Char)newArray_arrBounds :: (i, i)arrBounds=(i, i) -> Char -> ST s (STUArray s i Char)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(i, i)arrBounds(Int -> Charchr0){-# INLINEunsafeRead#-}unsafeRead :: STUArray s i Char -> Int -> ST s CharunsafeRead(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)=STRep s Char -> ST s Charforall s a. STRep s a -> ST s aST(STRep s Char -> ST s Char) -> STRep s Char -> ST s Charforall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)forall d.MutableByteArray# d -> Int# -> State# d -> (# State# d, Char# #)readWideCharArray#MutableByteArray# smarr#Int#i#State# ss1#of{(#s2# :: State# ss2#,e# :: Char#e##)->(#State# ss2#,Char# -> CharC#Char#e##)}{-# INLINEunsafeWrite#-}unsafeWrite :: STUArray s i Char -> Int -> Char -> ST s ()unsafeWrite(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)(C#e# :: Char#e#)=STRep s () -> ST s ()forall s a. STRep s a -> ST s aST(STRep s () -> ST s ()) -> STRep s () -> ST s ()forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> Char# -> State# s -> State# sforall d.MutableByteArray# d -> Int# -> Char# -> State# d -> State# dwriteWideCharArray#MutableByteArray# smarr#Int#i#Char#e#State# ss1#of{s2# :: State# ss2#->(#State# ss2#,()#)}instanceMArray(STUArrays)Int(STs)where{-# INLINEgetBounds#-}getBounds :: STUArray s i Int -> ST s (i, i)getBounds(STUArrayl :: ilu :: iu__)=(i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn(il,iu){-# INLINEgetNumElements#-}getNumElements :: STUArray s i Int -> ST s IntgetNumElements(STUArray__n :: Intn_)=Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturnIntn{-# INLINEunsafeNewArray_#-}unsafeNewArray_ :: (i, i) -> ST s (STUArray s i Int)unsafeNewArray_(l :: il,u :: iu)=(i, i) -> (Int# -> Int#) -> ST s (STUArray s i Int)forall i s e.Ix i =>(i, i) -> (Int# -> Int#) -> ST s (STUArray s i e)unsafeNewArraySTUArray_(il,iu)Int# -> Int#wORD_SCALE{-# INLINEnewArray_#-}newArray_ :: (i, i) -> ST s (STUArray s i Int)newArray_arrBounds :: (i, i)arrBounds=(i, i) -> Int -> ST s (STUArray s i Int)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(i, i)arrBounds0{-# INLINEunsafeRead#-}unsafeRead :: STUArray s i Int -> Int -> ST s IntunsafeRead(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)=STRep s Int -> ST s Intforall s a. STRep s a -> ST s aST(STRep s Int -> ST s Int) -> STRep s Int -> ST s Intforall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)forall d.MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)readIntArray#MutableByteArray# smarr#Int#i#State# ss1#of{(#s2# :: State# ss2#,e# :: Int#e##)->(#State# ss2#,Int# -> IntI#Int#e##)}{-# INLINEunsafeWrite#-}unsafeWrite :: STUArray s i Int -> Int -> Int -> ST s ()unsafeWrite(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)(I#e# :: Int#e#)=STRep s () -> ST s ()forall s a. STRep s a -> ST s aST(STRep s () -> ST s ()) -> STRep s () -> ST s ()forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> Int# -> State# s -> State# sforall d.MutableByteArray# d -> Int# -> Int# -> State# d -> State# dwriteIntArray#MutableByteArray# smarr#Int#i#Int#e#State# ss1#of{s2# :: State# ss2#->(#State# ss2#,()#)}instanceMArray(STUArrays)Word(STs)where{-# INLINEgetBounds#-}getBounds :: STUArray s i Word -> ST s (i, i)getBounds(STUArrayl :: ilu :: iu__)=(i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn(il,iu){-# INLINEgetNumElements#-}getNumElements :: STUArray s i Word -> ST s IntgetNumElements(STUArray__n :: Intn_)=Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturnIntn{-# INLINEunsafeNewArray_#-}unsafeNewArray_ :: (i, i) -> ST s (STUArray s i Word)unsafeNewArray_(l :: il,u :: iu)=(i, i) -> (Int# -> Int#) -> ST s (STUArray s i Word)forall i s e.Ix i =>(i, i) -> (Int# -> Int#) -> ST s (STUArray s i e)unsafeNewArraySTUArray_(il,iu)Int# -> Int#wORD_SCALE{-# INLINEnewArray_#-}newArray_ :: (i, i) -> ST s (STUArray s i Word)newArray_arrBounds :: (i, i)arrBounds=(i, i) -> Word -> ST s (STUArray s i Word)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(i, i)arrBounds0{-# INLINEunsafeRead#-}unsafeRead :: STUArray s i Word -> Int -> ST s WordunsafeRead(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)=STRep s Word -> ST s Wordforall s a. STRep s a -> ST s aST(STRep s Word -> ST s Word) -> STRep s Word -> ST s Wordforall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)forall d.MutableByteArray# d -> Int# -> State# d -> (# State# d, Word# #)readWordArray#MutableByteArray# smarr#Int#i#State# ss1#of{(#s2# :: State# ss2#,e# :: Word#e##)->(#State# ss2#,Word# -> WordW#Word#e##)}{-# INLINEunsafeWrite#-}unsafeWrite :: STUArray s i Word -> Int -> Word -> ST s ()unsafeWrite(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)(W#e# :: Word#e#)=STRep s () -> ST s ()forall s a. STRep s a -> ST s aST(STRep s () -> ST s ()) -> STRep s () -> ST s ()forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> Word# -> State# s -> State# sforall d.MutableByteArray# d -> Int# -> Word# -> State# d -> State# dwriteWordArray#MutableByteArray# smarr#Int#i#Word#e#State# ss1#of{s2# :: State# ss2#->(#State# ss2#,()#)}instanceMArray(STUArrays)(Ptra)(STs)where{-# INLINEgetBounds#-}getBounds :: STUArray s i (Ptr a) -> ST s (i, i)getBounds(STUArrayl :: ilu :: iu__)=(i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn(il,iu){-# INLINEgetNumElements#-}getNumElements :: STUArray s i (Ptr a) -> ST s IntgetNumElements(STUArray__n :: Intn_)=Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturnIntn{-# INLINEunsafeNewArray_#-}unsafeNewArray_ :: (i, i) -> ST s (STUArray s i (Ptr a))unsafeNewArray_(l :: il,u :: iu)=(i, i) -> (Int# -> Int#) -> ST s (STUArray s i (Ptr a))forall i s e.Ix i =>(i, i) -> (Int# -> Int#) -> ST s (STUArray s i e)unsafeNewArraySTUArray_(il,iu)Int# -> Int#wORD_SCALE{-# INLINEnewArray_#-}newArray_ :: (i, i) -> ST s (STUArray s i (Ptr a))newArray_arrBounds :: (i, i)arrBounds=(i, i) -> Ptr a -> ST s (STUArray s i (Ptr a))forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(i, i)arrBoundsPtr aforall a. Ptr anullPtr{-# INLINEunsafeRead#-}unsafeRead :: STUArray s i (Ptr a) -> Int -> ST s (Ptr a)unsafeRead(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)=STRep s (Ptr a) -> ST s (Ptr a)forall s a. STRep s a -> ST s aST(STRep s (Ptr a) -> ST s (Ptr a))-> STRep s (Ptr a) -> ST s (Ptr a)forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #)forall d.MutableByteArray# d -> Int# -> State# d -> (# State# d, Addr# #)readAddrArray#MutableByteArray# smarr#Int#i#State# ss1#of{(#s2# :: State# ss2#,e# :: Addr#e##)->(#State# ss2#,Addr# -> Ptr aforall a. Addr# -> Ptr aPtrAddr#e##)}{-# INLINEunsafeWrite#-}unsafeWrite :: STUArray s i (Ptr a) -> Int -> Ptr a -> ST s ()unsafeWrite(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)(Ptre# :: Addr#e#)=STRep s () -> ST s ()forall s a. STRep s a -> ST s aST(STRep s () -> ST s ()) -> STRep s () -> ST s ()forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> Addr# -> State# s -> State# sforall d.MutableByteArray# d -> Int# -> Addr# -> State# d -> State# dwriteAddrArray#MutableByteArray# smarr#Int#i#Addr#e#State# ss1#of{s2# :: State# ss2#->(#State# ss2#,()#)}instanceMArray(STUArrays)(FunPtra)(STs)where{-# INLINEgetBounds#-}getBounds :: STUArray s i (FunPtr a) -> ST s (i, i)getBounds(STUArrayl :: ilu :: iu__)=(i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn(il,iu){-# INLINEgetNumElements#-}getNumElements :: STUArray s i (FunPtr a) -> ST s IntgetNumElements(STUArray__n :: Intn_)=Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturnIntn{-# INLINEunsafeNewArray_#-}unsafeNewArray_ :: (i, i) -> ST s (STUArray s i (FunPtr a))unsafeNewArray_(l :: il,u :: iu)=(i, i) -> (Int# -> Int#) -> ST s (STUArray s i (FunPtr a))forall i s e.Ix i =>(i, i) -> (Int# -> Int#) -> ST s (STUArray s i e)unsafeNewArraySTUArray_(il,iu)Int# -> Int#wORD_SCALE{-# INLINEnewArray_#-}newArray_ :: (i, i) -> ST s (STUArray s i (FunPtr a))newArray_arrBounds :: (i, i)arrBounds=(i, i) -> FunPtr a -> ST s (STUArray s i (FunPtr a))forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(i, i)arrBoundsFunPtr aforall a. FunPtr anullFunPtr{-# INLINEunsafeRead#-}unsafeRead :: STUArray s i (FunPtr a) -> Int -> ST s (FunPtr a)unsafeRead(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)=STRep s (FunPtr a) -> ST s (FunPtr a)forall s a. STRep s a -> ST s aST(STRep s (FunPtr a) -> ST s (FunPtr a))-> STRep s (FunPtr a) -> ST s (FunPtr a)forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #)forall d.MutableByteArray# d -> Int# -> State# d -> (# State# d, Addr# #)readAddrArray#MutableByteArray# smarr#Int#i#State# ss1#of{(#s2# :: State# ss2#,e# :: Addr#e##)->(#State# ss2#,Addr# -> FunPtr aforall a. Addr# -> FunPtr aFunPtrAddr#e##)}{-# INLINEunsafeWrite#-}unsafeWrite :: STUArray s i (FunPtr a) -> Int -> FunPtr a -> ST s ()unsafeWrite(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)(FunPtre# :: Addr#e#)=STRep s () -> ST s ()forall s a. STRep s a -> ST s aST(STRep s () -> ST s ()) -> STRep s () -> ST s ()forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> Addr# -> State# s -> State# sforall d.MutableByteArray# d -> Int# -> Addr# -> State# d -> State# dwriteAddrArray#MutableByteArray# smarr#Int#i#Addr#e#State# ss1#of{s2# :: State# ss2#->(#State# ss2#,()#)}instanceMArray(STUArrays)Float(STs)where{-# INLINEgetBounds#-}getBounds :: STUArray s i Float -> ST s (i, i)getBounds(STUArrayl :: ilu :: iu__)=(i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn(il,iu){-# INLINEgetNumElements#-}getNumElements :: STUArray s i Float -> ST s IntgetNumElements(STUArray__n :: Intn_)=Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturnIntn{-# INLINEunsafeNewArray_#-}unsafeNewArray_ :: (i, i) -> ST s (STUArray s i Float)unsafeNewArray_(l :: il,u :: iu)=(i, i) -> (Int# -> Int#) -> ST s (STUArray s i Float)forall i s e.Ix i =>(i, i) -> (Int# -> Int#) -> ST s (STUArray s i e)unsafeNewArraySTUArray_(il,iu)Int# -> Int#fLOAT_SCALE{-# INLINEnewArray_#-}newArray_ :: (i, i) -> ST s (STUArray s i Float)newArray_arrBounds :: (i, i)arrBounds=(i, i) -> Float -> ST s (STUArray s i Float)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(i, i)arrBounds0{-# INLINEunsafeRead#-}unsafeRead :: STUArray s i Float -> Int -> ST s FloatunsafeRead(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)=STRep s Float -> ST s Floatforall s a. STRep s a -> ST s aST(STRep s Float -> ST s Float) -> STRep s Float -> ST s Floatforall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #)forall d.MutableByteArray# d -> Int# -> State# d -> (# State# d, Float# #)readFloatArray#MutableByteArray# smarr#Int#i#State# ss1#of{(#s2# :: State# ss2#,e# :: Float#e##)->(#State# ss2#,Float# -> FloatF#Float#e##)}{-# INLINEunsafeWrite#-}unsafeWrite :: STUArray s i Float -> Int -> Float -> ST s ()unsafeWrite(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)(F#e# :: Float#e#)=STRep s () -> ST s ()forall s a. STRep s a -> ST s aST(STRep s () -> ST s ()) -> STRep s () -> ST s ()forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> Float# -> State# s -> State# sforall d.MutableByteArray# d -> Int# -> Float# -> State# d -> State# dwriteFloatArray#MutableByteArray# smarr#Int#i#Float#e#State# ss1#of{s2# :: State# ss2#->(#State# ss2#,()#)}instanceMArray(STUArrays)Double(STs)where{-# INLINEgetBounds#-}getBounds :: STUArray s i Double -> ST s (i, i)getBounds(STUArrayl :: ilu :: iu__)=(i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn(il,iu){-# INLINEgetNumElements#-}getNumElements :: STUArray s i Double -> ST s IntgetNumElements(STUArray__n :: Intn_)=Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturnIntn{-# INLINEunsafeNewArray_#-}unsafeNewArray_ :: (i, i) -> ST s (STUArray s i Double)unsafeNewArray_(l :: il,u :: iu)=(i, i) -> (Int# -> Int#) -> ST s (STUArray s i Double)forall i s e.Ix i =>(i, i) -> (Int# -> Int#) -> ST s (STUArray s i e)unsafeNewArraySTUArray_(il,iu)Int# -> Int#dOUBLE_SCALE{-# INLINEnewArray_#-}newArray_ :: (i, i) -> ST s (STUArray s i Double)newArray_arrBounds :: (i, i)arrBounds=(i, i) -> Double -> ST s (STUArray s i Double)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(i, i)arrBounds0{-# INLINEunsafeRead#-}unsafeRead :: STUArray s i Double -> Int -> ST s DoubleunsafeRead(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)=STRep s Double -> ST s Doubleforall s a. STRep s a -> ST s aST(STRep s Double -> ST s Double) -> STRep s Double -> ST s Doubleforall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #)forall d.MutableByteArray# d -> Int# -> State# d -> (# State# d, Double# #)readDoubleArray#MutableByteArray# smarr#Int#i#State# ss1#of{(#s2# :: State# ss2#,e# :: Double#e##)->(#State# ss2#,Double# -> DoubleD#Double#e##)}{-# INLINEunsafeWrite#-}unsafeWrite :: STUArray s i Double -> Int -> Double -> ST s ()unsafeWrite(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)(D#e# :: Double#e#)=STRep s () -> ST s ()forall s a. STRep s a -> ST s aST(STRep s () -> ST s ()) -> STRep s () -> ST s ()forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> Double# -> State# s -> State# sforall d.MutableByteArray# d -> Int# -> Double# -> State# d -> State# dwriteDoubleArray#MutableByteArray# smarr#Int#i#Double#e#State# ss1#of{s2# :: State# ss2#->(#State# ss2#,()#)}instanceMArray(STUArrays)(StablePtra)(STs)where{-# INLINEgetBounds#-}getBounds :: STUArray s i (StablePtr a) -> ST s (i, i)getBounds(STUArrayl :: ilu :: iu__)=(i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn(il,iu){-# INLINEgetNumElements#-}getNumElements :: STUArray s i (StablePtr a) -> ST s IntgetNumElements(STUArray__n :: Intn_)=Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturnIntn{-# INLINEunsafeNewArray_#-}unsafeNewArray_ :: (i, i) -> ST s (STUArray s i (StablePtr a))unsafeNewArray_(l :: il,u :: iu)=(i, i) -> (Int# -> Int#) -> ST s (STUArray s i (StablePtr a))forall i s e.Ix i =>(i, i) -> (Int# -> Int#) -> ST s (STUArray s i e)unsafeNewArraySTUArray_(il,iu)Int# -> Int#wORD_SCALE{-# INLINEnewArray_#-}newArray_ :: (i, i) -> ST s (STUArray s i (StablePtr a))newArray_arrBounds :: (i, i)arrBounds=(i, i) -> StablePtr a -> ST s (STUArray s i (StablePtr a))forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(i, i)arrBounds(Ptr () -> StablePtr aforall a. Ptr () -> StablePtr acastPtrToStablePtrPtr ()forall a. Ptr anullPtr){-# INLINEunsafeRead#-}unsafeRead :: STUArray s i (StablePtr a) -> Int -> ST s (StablePtr a)unsafeRead(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)=STRep s (StablePtr a) -> ST s (StablePtr a)forall s a. STRep s a -> ST s aST(STRep s (StablePtr a) -> ST s (StablePtr a))-> STRep s (StablePtr a) -> ST s (StablePtr a)forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s-> Int# -> State# s -> (# State# s, StablePtr# a #)forall d a.MutableByteArray# d-> Int# -> State# d -> (# State# d, StablePtr# a #)readStablePtrArray#MutableByteArray# smarr#Int#i#State# ss1#of{(#s2# :: State# ss2#,e# :: StablePtr# ae##)->(#State# ss2#,StablePtr# a -> StablePtr aforall a. StablePtr# a -> StablePtr aStablePtrStablePtr# ae##)}{-# INLINEunsafeWrite#-}unsafeWrite :: STUArray s i (StablePtr a) -> Int -> StablePtr a -> ST s ()unsafeWrite(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)(StablePtre# :: StablePtr# ae#)=STRep s () -> ST s ()forall s a. STRep s a -> ST s aST(STRep s () -> ST s ()) -> STRep s () -> ST s ()forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# sforall d a.MutableByteArray# d -> Int# -> StablePtr# a -> State# d -> State# dwriteStablePtrArray#MutableByteArray# smarr#Int#i#StablePtr# ae#State# ss1#of{s2# :: State# ss2#->(#State# ss2#,()#)}instanceMArray(STUArrays)Int8(STs)where{-# INLINEgetBounds#-}getBounds :: STUArray s i Int8 -> ST s (i, i)getBounds(STUArrayl :: ilu :: iu__)=(i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn(il,iu){-# INLINEgetNumElements#-}getNumElements :: STUArray s i Int8 -> ST s IntgetNumElements(STUArray__n :: Intn_)=Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturnIntn{-# INLINEunsafeNewArray_#-}unsafeNewArray_ :: (i, i) -> ST s (STUArray s i Int8)unsafeNewArray_(l :: il,u :: iu)=(i, i) -> (Int# -> Int#) -> ST s (STUArray s i Int8)forall i s e.Ix i =>(i, i) -> (Int# -> Int#) -> ST s (STUArray s i e)unsafeNewArraySTUArray_(il,iu)(\x :: Int#x->Int#x){-# INLINEnewArray_#-}newArray_ :: (i, i) -> ST s (STUArray s i Int8)newArray_arrBounds :: (i, i)arrBounds=(i, i) -> Int8 -> ST s (STUArray s i Int8)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(i, i)arrBounds0{-# INLINEunsafeRead#-}unsafeRead :: STUArray s i Int8 -> Int -> ST s Int8unsafeRead(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)=STRep s Int8 -> ST s Int8forall s a. STRep s a -> ST s aST(STRep s Int8 -> ST s Int8) -> STRep s Int8 -> ST s Int8forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)forall d.MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)readInt8Array#MutableByteArray# smarr#Int#i#State# ss1#of{(#s2# :: State# ss2#,e# :: Int#e##)->(#State# ss2#,Int# -> Int8I8#Int#e##)}{-# INLINEunsafeWrite#-}unsafeWrite :: STUArray s i Int8 -> Int -> Int8 -> ST s ()unsafeWrite(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)(I8#e# :: Int#e#)=STRep s () -> ST s ()forall s a. STRep s a -> ST s aST(STRep s () -> ST s ()) -> STRep s () -> ST s ()forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> Int# -> State# s -> State# sforall d.MutableByteArray# d -> Int# -> Int# -> State# d -> State# dwriteInt8Array#MutableByteArray# smarr#Int#i#Int#e#State# ss1#of{s2# :: State# ss2#->(#State# ss2#,()#)}instanceMArray(STUArrays)Int16(STs)where{-# INLINEgetBounds#-}getBounds :: STUArray s i Int16 -> ST s (i, i)getBounds(STUArrayl :: ilu :: iu__)=(i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn(il,iu){-# INLINEgetNumElements#-}getNumElements :: STUArray s i Int16 -> ST s IntgetNumElements(STUArray__n :: Intn_)=Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturnIntn{-# INLINEunsafeNewArray_#-}unsafeNewArray_ :: (i, i) -> ST s (STUArray s i Int16)unsafeNewArray_(l :: il,u :: iu)=(i, i) -> (Int# -> Int#) -> ST s (STUArray s i Int16)forall i s e.Ix i =>(i, i) -> (Int# -> Int#) -> ST s (STUArray s i e)unsafeNewArraySTUArray_(il,iu)(Int# -> Int# -> Int#safe_scale2#){-# INLINEnewArray_#-}newArray_ :: (i, i) -> ST s (STUArray s i Int16)newArray_arrBounds :: (i, i)arrBounds=(i, i) -> Int16 -> ST s (STUArray s i Int16)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(i, i)arrBounds0{-# INLINEunsafeRead#-}unsafeRead :: STUArray s i Int16 -> Int -> ST s Int16unsafeRead(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)=STRep s Int16 -> ST s Int16forall s a. STRep s a -> ST s aST(STRep s Int16 -> ST s Int16) -> STRep s Int16 -> ST s Int16forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)forall d.MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)readInt16Array#MutableByteArray# smarr#Int#i#State# ss1#of{(#s2# :: State# ss2#,e# :: Int#e##)->(#State# ss2#,Int# -> Int16I16#Int#e##)}{-# INLINEunsafeWrite#-}unsafeWrite :: STUArray s i Int16 -> Int -> Int16 -> ST s ()unsafeWrite(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)(I16#e# :: Int#e#)=STRep s () -> ST s ()forall s a. STRep s a -> ST s aST(STRep s () -> ST s ()) -> STRep s () -> ST s ()forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> Int# -> State# s -> State# sforall d.MutableByteArray# d -> Int# -> Int# -> State# d -> State# dwriteInt16Array#MutableByteArray# smarr#Int#i#Int#e#State# ss1#of{s2# :: State# ss2#->(#State# ss2#,()#)}instanceMArray(STUArrays)Int32(STs)where{-# INLINEgetBounds#-}getBounds :: STUArray s i Int32 -> ST s (i, i)getBounds(STUArrayl :: ilu :: iu__)=(i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn(il,iu){-# INLINEgetNumElements#-}getNumElements :: STUArray s i Int32 -> ST s IntgetNumElements(STUArray__n :: Intn_)=Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturnIntn{-# INLINEunsafeNewArray_#-}unsafeNewArray_ :: (i, i) -> ST s (STUArray s i Int32)unsafeNewArray_(l :: il,u :: iu)=(i, i) -> (Int# -> Int#) -> ST s (STUArray s i Int32)forall i s e.Ix i =>(i, i) -> (Int# -> Int#) -> ST s (STUArray s i e)unsafeNewArraySTUArray_(il,iu)(Int# -> Int# -> Int#safe_scale4#){-# INLINEnewArray_#-}newArray_ :: (i, i) -> ST s (STUArray s i Int32)newArray_arrBounds :: (i, i)arrBounds=(i, i) -> Int32 -> ST s (STUArray s i Int32)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(i, i)arrBounds0{-# INLINEunsafeRead#-}unsafeRead :: STUArray s i Int32 -> Int -> ST s Int32unsafeRead(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)=STRep s Int32 -> ST s Int32forall s a. STRep s a -> ST s aST(STRep s Int32 -> ST s Int32) -> STRep s Int32 -> ST s Int32forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)forall d.MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)readInt32Array#MutableByteArray# smarr#Int#i#State# ss1#of{(#s2# :: State# ss2#,e# :: Int#e##)->(#State# ss2#,Int# -> Int32I32#Int#e##)}{-# INLINEunsafeWrite#-}unsafeWrite :: STUArray s i Int32 -> Int -> Int32 -> ST s ()unsafeWrite(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)(I32#e# :: Int#e#)=STRep s () -> ST s ()forall s a. STRep s a -> ST s aST(STRep s () -> ST s ()) -> STRep s () -> ST s ()forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> Int# -> State# s -> State# sforall d.MutableByteArray# d -> Int# -> Int# -> State# d -> State# dwriteInt32Array#MutableByteArray# smarr#Int#i#Int#e#State# ss1#of{s2# :: State# ss2#->(#State# ss2#,()#)}instanceMArray(STUArrays)Int64(STs)where{-# INLINEgetBounds#-}getBounds :: STUArray s i Int64 -> ST s (i, i)getBounds(STUArrayl :: ilu :: iu__)=(i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn(il,iu){-# INLINEgetNumElements#-}getNumElements :: STUArray s i Int64 -> ST s IntgetNumElements(STUArray__n :: Intn_)=Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturnIntn{-# INLINEunsafeNewArray_#-}unsafeNewArray_ :: (i, i) -> ST s (STUArray s i Int64)unsafeNewArray_(l :: il,u :: iu)=(i, i) -> (Int# -> Int#) -> ST s (STUArray s i Int64)forall i s e.Ix i =>(i, i) -> (Int# -> Int#) -> ST s (STUArray s i e)unsafeNewArraySTUArray_(il,iu)(Int# -> Int# -> Int#safe_scale8#){-# INLINEnewArray_#-}newArray_ :: (i, i) -> ST s (STUArray s i Int64)newArray_arrBounds :: (i, i)arrBounds=(i, i) -> Int64 -> ST s (STUArray s i Int64)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(i, i)arrBounds0{-# INLINEunsafeRead#-}unsafeRead :: STUArray s i Int64 -> Int -> ST s Int64unsafeRead(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)=STRep s Int64 -> ST s Int64forall s a. STRep s a -> ST s aST(STRep s Int64 -> ST s Int64) -> STRep s Int64 -> ST s Int64forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)forall d.MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)readInt64Array#MutableByteArray# smarr#Int#i#State# ss1#of{(#s2# :: State# ss2#,e# :: Int#e##)->(#State# ss2#,Int# -> Int64I64#Int#e##)}{-# INLINEunsafeWrite#-}unsafeWrite :: STUArray s i Int64 -> Int -> Int64 -> ST s ()unsafeWrite(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)(I64#e# :: Int#e#)=STRep s () -> ST s ()forall s a. STRep s a -> ST s aST(STRep s () -> ST s ()) -> STRep s () -> ST s ()forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> Int# -> State# s -> State# sforall d.MutableByteArray# d -> Int# -> Int# -> State# d -> State# dwriteInt64Array#MutableByteArray# smarr#Int#i#Int#e#State# ss1#of{s2# :: State# ss2#->(#State# ss2#,()#)}instanceMArray(STUArrays)Word8(STs)where{-# INLINEgetBounds#-}getBounds :: STUArray s i Word8 -> ST s (i, i)getBounds(STUArrayl :: ilu :: iu__)=(i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn(il,iu){-# INLINEgetNumElements#-}getNumElements :: STUArray s i Word8 -> ST s IntgetNumElements(STUArray__n :: Intn_)=Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturnIntn{-# INLINEunsafeNewArray_#-}unsafeNewArray_ :: (i, i) -> ST s (STUArray s i Word8)unsafeNewArray_(l :: il,u :: iu)=(i, i) -> (Int# -> Int#) -> ST s (STUArray s i Word8)forall i s e.Ix i =>(i, i) -> (Int# -> Int#) -> ST s (STUArray s i e)unsafeNewArraySTUArray_(il,iu)(\x :: Int#x->Int#x){-# INLINEnewArray_#-}newArray_ :: (i, i) -> ST s (STUArray s i Word8)newArray_arrBounds :: (i, i)arrBounds=(i, i) -> Word8 -> ST s (STUArray s i Word8)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(i, i)arrBounds0{-# INLINEunsafeRead#-}unsafeRead :: STUArray s i Word8 -> Int -> ST s Word8unsafeRead(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)=STRep s Word8 -> ST s Word8forall s a. STRep s a -> ST s aST(STRep s Word8 -> ST s Word8) -> STRep s Word8 -> ST s Word8forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)forall d.MutableByteArray# d -> Int# -> State# d -> (# State# d, Word# #)readWord8Array#MutableByteArray# smarr#Int#i#State# ss1#of{(#s2# :: State# ss2#,e# :: Word#e##)->(#State# ss2#,Word# -> Word8W8#Word#e##)}{-# INLINEunsafeWrite#-}unsafeWrite :: STUArray s i Word8 -> Int -> Word8 -> ST s ()unsafeWrite(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)(W8#e# :: Word#e#)=STRep s () -> ST s ()forall s a. STRep s a -> ST s aST(STRep s () -> ST s ()) -> STRep s () -> ST s ()forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> Word# -> State# s -> State# sforall d.MutableByteArray# d -> Int# -> Word# -> State# d -> State# dwriteWord8Array#MutableByteArray# smarr#Int#i#Word#e#State# ss1#of{s2# :: State# ss2#->(#State# ss2#,()#)}instanceMArray(STUArrays)Word16(STs)where{-# INLINEgetBounds#-}getBounds :: STUArray s i Word16 -> ST s (i, i)getBounds(STUArrayl :: ilu :: iu__)=(i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn(il,iu){-# INLINEgetNumElements#-}getNumElements :: STUArray s i Word16 -> ST s IntgetNumElements(STUArray__n :: Intn_)=Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturnIntn{-# INLINEunsafeNewArray_#-}unsafeNewArray_ :: (i, i) -> ST s (STUArray s i Word16)unsafeNewArray_(l :: il,u :: iu)=(i, i) -> (Int# -> Int#) -> ST s (STUArray s i Word16)forall i s e.Ix i =>(i, i) -> (Int# -> Int#) -> ST s (STUArray s i e)unsafeNewArraySTUArray_(il,iu)(Int# -> Int# -> Int#safe_scale2#){-# INLINEnewArray_#-}newArray_ :: (i, i) -> ST s (STUArray s i Word16)newArray_arrBounds :: (i, i)arrBounds=(i, i) -> Word16 -> ST s (STUArray s i Word16)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(i, i)arrBounds0{-# INLINEunsafeRead#-}unsafeRead :: STUArray s i Word16 -> Int -> ST s Word16unsafeRead(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)=STRep s Word16 -> ST s Word16forall s a. STRep s a -> ST s aST(STRep s Word16 -> ST s Word16) -> STRep s Word16 -> ST s Word16forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)forall d.MutableByteArray# d -> Int# -> State# d -> (# State# d, Word# #)readWord16Array#MutableByteArray# smarr#Int#i#State# ss1#of{(#s2# :: State# ss2#,e# :: Word#e##)->(#State# ss2#,Word# -> Word16W16#Word#e##)}{-# INLINEunsafeWrite#-}unsafeWrite :: STUArray s i Word16 -> Int -> Word16 -> ST s ()unsafeWrite(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)(W16#e# :: Word#e#)=STRep s () -> ST s ()forall s a. STRep s a -> ST s aST(STRep s () -> ST s ()) -> STRep s () -> ST s ()forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> Word# -> State# s -> State# sforall d.MutableByteArray# d -> Int# -> Word# -> State# d -> State# dwriteWord16Array#MutableByteArray# smarr#Int#i#Word#e#State# ss1#of{s2# :: State# ss2#->(#State# ss2#,()#)}instanceMArray(STUArrays)Word32(STs)where{-# INLINEgetBounds#-}getBounds :: STUArray s i Word32 -> ST s (i, i)getBounds(STUArrayl :: ilu :: iu__)=(i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn(il,iu){-# INLINEgetNumElements#-}getNumElements :: STUArray s i Word32 -> ST s IntgetNumElements(STUArray__n :: Intn_)=Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturnIntn{-# INLINEunsafeNewArray_#-}unsafeNewArray_ :: (i, i) -> ST s (STUArray s i Word32)unsafeNewArray_(l :: il,u :: iu)=(i, i) -> (Int# -> Int#) -> ST s (STUArray s i Word32)forall i s e.Ix i =>(i, i) -> (Int# -> Int#) -> ST s (STUArray s i e)unsafeNewArraySTUArray_(il,iu)(Int# -> Int# -> Int#safe_scale4#){-# INLINEnewArray_#-}newArray_ :: (i, i) -> ST s (STUArray s i Word32)newArray_arrBounds :: (i, i)arrBounds=(i, i) -> Word32 -> ST s (STUArray s i Word32)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(i, i)arrBounds0{-# INLINEunsafeRead#-}unsafeRead :: STUArray s i Word32 -> Int -> ST s Word32unsafeRead(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)=STRep s Word32 -> ST s Word32forall s a. STRep s a -> ST s aST(STRep s Word32 -> ST s Word32) -> STRep s Word32 -> ST s Word32forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)forall d.MutableByteArray# d -> Int# -> State# d -> (# State# d, Word# #)readWord32Array#MutableByteArray# smarr#Int#i#State# ss1#of{(#s2# :: State# ss2#,e# :: Word#e##)->(#State# ss2#,Word# -> Word32W32#Word#e##)}{-# INLINEunsafeWrite#-}unsafeWrite :: STUArray s i Word32 -> Int -> Word32 -> ST s ()unsafeWrite(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)(W32#e# :: Word#e#)=STRep s () -> ST s ()forall s a. STRep s a -> ST s aST(STRep s () -> ST s ()) -> STRep s () -> ST s ()forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> Word# -> State# s -> State# sforall d.MutableByteArray# d -> Int# -> Word# -> State# d -> State# dwriteWord32Array#MutableByteArray# smarr#Int#i#Word#e#State# ss1#of{s2# :: State# ss2#->(#State# ss2#,()#)}instanceMArray(STUArrays)Word64(STs)where{-# INLINEgetBounds#-}getBounds :: STUArray s i Word64 -> ST s (i, i)getBounds(STUArrayl :: ilu :: iu__)=(i, i) -> ST s (i, i)forall (m :: * -> *) a. Monad m => a -> m areturn(il,iu){-# INLINEgetNumElements#-}getNumElements :: STUArray s i Word64 -> ST s IntgetNumElements(STUArray__n :: Intn_)=Int -> ST s Intforall (m :: * -> *) a. Monad m => a -> m areturnIntn{-# INLINEunsafeNewArray_#-}unsafeNewArray_ :: (i, i) -> ST s (STUArray s i Word64)unsafeNewArray_(l :: il,u :: iu)=(i, i) -> (Int# -> Int#) -> ST s (STUArray s i Word64)forall i s e.Ix i =>(i, i) -> (Int# -> Int#) -> ST s (STUArray s i e)unsafeNewArraySTUArray_(il,iu)(Int# -> Int# -> Int#safe_scale8#){-# INLINEnewArray_#-}newArray_ :: (i, i) -> ST s (STUArray s i Word64)newArray_arrBounds :: (i, i)arrBounds=(i, i) -> Word64 -> ST s (STUArray s i Word64)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> e -> m (a i e)newArray(i, i)arrBounds0{-# INLINEunsafeRead#-}unsafeRead :: STUArray s i Word64 -> Int -> ST s Word64unsafeRead(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)=STRep s Word64 -> ST s Word64forall s a. STRep s a -> ST s aST(STRep s Word64 -> ST s Word64) -> STRep s Word64 -> ST s Word64forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)forall d.MutableByteArray# d -> Int# -> State# d -> (# State# d, Word# #)readWord64Array#MutableByteArray# smarr#Int#i#State# ss1#of{(#s2# :: State# ss2#,e# :: Word#e##)->(#State# ss2#,Word# -> Word64W64#Word#e##)}{-# INLINEunsafeWrite#-}unsafeWrite :: STUArray s i Word64 -> Int -> Word64 -> ST s ()unsafeWrite(STUArray___marr# :: MutableByteArray# smarr#)(I#i# :: Int#i#)(W64#e# :: Word#e#)=STRep s () -> ST s ()forall s a. STRep s a -> ST s aST(STRep s () -> ST s ()) -> STRep s () -> ST s ()forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int# -> Word# -> State# s -> State# sforall d.MutableByteArray# d -> Int# -> Word# -> State# d -> State# dwriteWord64Array#MutableByteArray# smarr#Int#i#Word#e#State# ss1#of{s2# :: State# ss2#->(#State# ss2#,()#)}------------------------------------------------------------------------------- Translation between elements and bytesbOOL_SCALE,wORD_SCALE,dOUBLE_SCALE,fLOAT_SCALE::Int#->Int#bOOL_SCALE :: Int# -> Int#bOOL_SCALEn# :: Int#n#=-- + 7 to handle case where n is not divisible by 8(Int#n#Int# -> Int# -> Int#+#7#)Int# -> Int# -> Int#`uncheckedIShiftRA#`3#wORD_SCALE :: Int# -> Int#wORD_SCALEn# :: Int#n#=Int# -> Int# -> Int#safe_scaleInt#scale#Int#n#where!(I#scale# :: Int#scale#)=SIZEOF_HSWORDdOUBLE_SCALE :: Int# -> Int#dOUBLE_SCALEn# :: Int#n#=Int# -> Int# -> Int#safe_scaleInt#scale#Int#n#where!(I#scale# :: Int#scale#)=SIZEOF_HSDOUBLEfLOAT_SCALE :: Int# -> Int#fLOAT_SCALEn# :: Int#n#=Int# -> Int# -> Int#safe_scaleInt#scale#Int#n#where!(I#scale# :: Int#scale#)=SIZEOF_HSFLOATsafe_scale::Int#->Int#->Int#safe_scale :: Int# -> Int# -> Int#safe_scalescale# :: Int#scale#n# :: Int#n#|Bool -> BoolnotBooloverflow=Int#res#|Boolotherwise=[Char] -> Int#forall a. HasCallStack => [Char] -> aerror([Char] -> Int#) -> [Char] -> Int#forall a b. (a -> b) -> a -> b$"Data.Array.Base.safe_scale: Overflow; scale: "[Char] -> [Char] -> [Char]forall a. [a] -> [a] -> [a]++Int -> [Char]forall a. Show a => a -> [Char]show(Int# -> IntI#Int#scale#)[Char] -> [Char] -> [Char]forall a. [a] -> [a] -> [a]++", n: "[Char] -> [Char] -> [Char]forall a. [a] -> [a] -> [a]++Int -> [Char]forall a. Show a => a -> [Char]show(Int# -> IntI#Int#n#)where!res# :: Int#res#=Int#scale#Int# -> Int# -> Int#*#Int#n#!overflow :: Booloverflow=Int# -> BoolisTrue#(Int#maxN#Int# -> Int# -> Int#`divInt#`Int#scale#Int# -> Int# -> Int#<#Int#n#)!(I#maxN# :: Int#maxN#)=Intforall a. Bounded a => amaxBound{-# INLINEsafe_scale#-}-- | The index of the word which the given @Bool@ array elements falls within.bOOL_INDEX::Int#->Int##if SIZEOF_HSWORD == 4bOOL_INDEXi#=i#`uncheckedIShiftRA#`5##elif SIZEOF_HSWORD == 8bOOL_INDEX :: Int# -> Int#bOOL_INDEXi# :: Int#i#=Int#i#Int# -> Int# -> Int#`uncheckedIShiftRA#`6##endifbOOL_BIT,bOOL_NOT_BIT::Int#->Word#bOOL_BIT :: Int# -> Word#bOOL_BITn# :: Int#n#=Int# -> Word#int2Word#1#Word# -> Int# -> Word#`uncheckedShiftL#`(Word# -> Int#word2Int#(Int# -> Word#int2Word#Int#n#Word# -> Word# -> Word#`and#`Word#mask#))where!(W#mask# :: Word#mask#)=SIZEOF_HSWORD*8-1bOOL_NOT_BIT :: Int# -> Word#bOOL_NOT_BITn# :: Int#n#=Int# -> Word#bOOL_BITInt#n#Word# -> Word# -> Word#`xor#`Word#mb#where!(W#mb# :: Word#mb#)=Wordforall a. Bounded a => amaxBound------------------------------------------------------------------------------- Freezing-- | Converts a mutable array (any instance of 'MArray') to an-- immutable array (any instance of 'IArray') by taking a complete-- copy of it.freeze::(Ixi,MArrayaem,IArraybe)=>aie->m(bie){-# NOINLINE[1]freeze#-}freeze :: a i e -> m (b i e)freezemarr :: a i emarr=do(l :: il,u :: iu)<-a i e -> m (i, i)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> m (i, i)getBoundsa i emarrIntn<-a i e -> m Intforall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> m IntgetNumElementsa i emarr[e]es<-(Int -> m e) -> [Int] -> m [e]forall (t :: * -> *) (m :: * -> *) a b.(Traversable t, Monad m) =>(a -> m b) -> t a -> m (t b)mapM(a i e -> Int -> m eforall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> m eunsafeReada i emarr)[0..IntnInt -> Int -> Intforall a. Num a => a -> a -> a-1]-- The old array and index might not be well-behaved, so we need to-- use the safe array creation function here.b i e -> m (b i e)forall (m :: * -> *) a. Monad m => a -> m areturn((i, i) -> [e] -> b i eforall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>(i, i) -> [e] -> a i elistArray(il,iu)[e]es)freezeSTUArray::STUArraysie->STs(UArrayie)freezeSTUArray :: STUArray s i e -> ST s (UArray i e)freezeSTUArray(STUArrayl :: ilu :: iun :: Intnmarr# :: MutableByteArray# smarr#)=STRep s (UArray i e) -> ST s (UArray i e)forall s a. STRep s a -> ST s aST(STRep s (UArray i e) -> ST s (UArray i e))-> STRep s (UArray i e) -> ST s (UArray i e)forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseMutableByteArray# s -> Int#forall d. MutableByteArray# d -> Int#sizeofMutableByteArray#MutableByteArray# smarr#of{n# :: Int#n#->caseInt# -> State# s -> (# State# s, MutableByteArray# s #)forall d. Int# -> State# d -> (# State# d, MutableByteArray# d #)newByteArray#Int#n#State# ss1#of{(#s2# :: State# ss2#,marr'# :: MutableByteArray# smarr'##)->caseMutableByteArray# s -> MutableByteArray# s -> CSize -> IO (Ptr Any)forall s a.MutableByteArray# s -> MutableByteArray# s -> CSize -> IO (Ptr a)memcpy_freezeMutableByteArray# smarr'#MutableByteArray# smarr#(Int -> CSizeforall a b. (Integral a, Num b) => a -> bfromIntegral(Int# -> IntI#Int#n#))of{IOm :: State# RealWorld -> (# State# RealWorld, Ptr Any #)m->case(State# RealWorld -> (# State# RealWorld, Ptr Any #))-> State# s -> (# State# s, Any #)unsafeCoerce#State# RealWorld -> (# State# RealWorld, Ptr Any #)mState# ss2#of{(#s3# :: State# ss3#,_#)->caseMutableByteArray# s -> State# s -> (# State# s, ByteArray# #)forall d.MutableByteArray# d -> State# d -> (# State# d, ByteArray# #)unsafeFreezeByteArray#MutableByteArray# smarr'#State# ss3#of{(#s4# :: State# ss4#,arr# :: ByteArray#arr##)->(#State# ss4#,i -> i -> Int -> ByteArray# -> UArray i eforall i e. i -> i -> Int -> ByteArray# -> UArray i eUArrayiliuIntnByteArray#arr##)}}}}}foreignimportccallunsafe"memcpy"memcpy_freeze::MutableByteArray#s->MutableByteArray#s->CSize->IO(Ptra){-# RULES"freeze/STArray"freeze=ArrST.freezeSTArray"freeze/STUArray"freeze=freezeSTUArray#-}-- In-place conversion of mutable arrays to immutable ones places-- a proof obligation on the user: no other parts of your code can-- have a reference to the array at the point where you unsafely-- freeze it (and, subsequently mutate it, I suspect).{- | Converts an mutable array into an immutable array. The implementation may either simply cast the array from one type to the other without copying the array, or it may take a full copy of the array. Note that because the array is possibly not copied, any subsequent modifications made to the mutable version of the array may be shared with the immutable version. It is safe to use, therefore, if the mutable version is never modified after the freeze operation. The non-copying implementation is supported between certain pairs of array types only; one constraint is that the array types must have identical representations. In GHC, The following pairs of array types have a non-copying O(1) implementation of 'unsafeFreeze'. Because the optimised versions are enabled by specialisations, you will need to compile with optimisation (-O) to get them. * 'Data.Array.IO.IOUArray' -> 'Data.Array.Unboxed.UArray' * 'Data.Array.ST.STUArray' -> 'Data.Array.Unboxed.UArray' * 'Data.Array.IO.IOArray' -> 'Data.Array.Array' * 'Data.Array.ST.STArray' -> 'Data.Array.Array'-}{-# INLINE[1]unsafeFreeze#-}unsafeFreeze::(Ixi,MArrayaem,IArraybe)=>aie->m(bie)unsafeFreeze :: a i e -> m (b i e)unsafeFreeze=a i e -> m (b i e)forall i (a :: * -> * -> *) e (m :: * -> *) (b :: * -> * -> *).(Ix i, MArray a e m, IArray b e) =>a i e -> m (b i e)freeze{-# RULES"unsafeFreeze/STArray"unsafeFreeze=ArrST.unsafeFreezeSTArray"unsafeFreeze/STUArray"unsafeFreeze=unsafeFreezeSTUArray#-}------------------------------------------------------------------------------- Thawing-- | Converts an immutable array (any instance of 'IArray') into a-- mutable array (any instance of 'MArray') by taking a complete copy-- of it.thaw::(Ixi,IArrayae,MArraybem)=>aie->m(bie){-# NOINLINE[1]thaw#-}thaw :: a i e -> m (b i e)thawarr :: a i earr=casea i e -> (i, i)forall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> (i, i)boundsa i earrof(l :: il,u :: iu)->dob i emarr<-(i, i) -> m (b i e)forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>(i, i) -> m (a i e)newArray_(il,iu)letn :: Intn=(i, i) -> Intforall a. Ix a => (a, a) -> IntsafeRangeSize(il,iu)[m ()] -> m ()forall (t :: * -> *) (m :: * -> *) a.(Foldable t, Monad m) =>t (m a) -> m ()sequence_[b i e -> Int -> e -> m ()forall (a :: * -> * -> *) e (m :: * -> *) i.(MArray a e m, Ix i) =>a i e -> Int -> e -> m ()unsafeWriteb i emarrInti(a i e -> Int -> eforall (a :: * -> * -> *) e i.(IArray a e, Ix i) =>a i e -> Int -> eunsafeAta i earrInti)|Inti<-[0..IntnInt -> Int -> Intforall a. Num a => a -> a -> a-1]]b i e -> m (b i e)forall (m :: * -> *) a. Monad m => a -> m areturnb i emarrthawSTUArray::UArrayie->STs(STUArraysie)thawSTUArray :: UArray i e -> ST s (STUArray s i e)thawSTUArray(UArrayl :: ilu :: iun :: Intnarr# :: ByteArray#arr#)=STRep s (STUArray s i e) -> ST s (STUArray s i e)forall s a. STRep s a -> ST s aST(STRep s (STUArray s i e) -> ST s (STUArray s i e))-> STRep s (STUArray s i e) -> ST s (STUArray s i e)forall a b. (a -> b) -> a -> b$\s1# :: State# ss1#->caseByteArray# -> Int#sizeofByteArray#ByteArray#arr#of{n# :: Int#n#->caseInt# -> State# s -> (# State# s, MutableByteArray# s #)forall d. Int# -> State# d -> (# State# d, MutableByteArray# d #)newByteArray#Int#n#State# ss1#of{(#s2# :: State# ss2#,marr# :: MutableByteArray# smarr##)->caseMutableByteArray# s -> ByteArray# -> CSize -> IO (Ptr Any)forall s a.MutableByteArray# s -> ByteArray# -> CSize -> IO (Ptr a)memcpy_thawMutableByteArray# smarr#ByteArray#arr#(Int -> CSizeforall a b. (Integral a, Num b) => a -> bfromIntegral(Int# -> IntI#Int#n#))of{IOm :: State# RealWorld -> (# State# RealWorld, Ptr Any #)m->case(State# RealWorld -> (# State# RealWorld, Ptr Any #))-> State# s -> (# State# s, Any #)unsafeCoerce#State# RealWorld -> (# State# RealWorld, Ptr Any #)mState# ss2#of{(#s3# :: State# ss3#,_#)->(#State# ss3#,i -> i -> Int -> MutableByteArray# s -> STUArray s i eforall s i e.i -> i -> Int -> MutableByteArray# s -> STUArray s i eSTUArrayiliuIntnMutableByteArray# smarr##)}}}}foreignimportccallunsafe"memcpy"memcpy_thaw::MutableByteArray#s->ByteArray#->CSize->IO(Ptra){-# RULES"thaw/STArray"thaw=ArrST.thawSTArray"thaw/STUArray"thaw=thawSTUArray#-}-- In-place conversion of immutable arrays to mutable ones places-- a proof obligation on the user: no other parts of your code can-- have a reference to the array at the point where you unsafely-- thaw it (and, subsequently mutate it, I suspect).{- | Converts an immutable array into a mutable array. The implementation may either simply cast the array from one type to the other without copying the array, or it may take a full copy of the array. Note that because the array is possibly not copied, any subsequent modifications made to the mutable version of the array may be shared with the immutable version. It is only safe to use, therefore, if the immutable array is never referenced again in this thread, and there is no possibility that it can be also referenced in another thread. If you use an unsafeThaw/write/unsafeFreeze sequence in a multi-threaded setting, then you must ensure that this sequence is atomic with respect to other threads, or a garbage collector crash may result (because the write may be writing to a frozen array). The non-copying implementation is supported between certain pairs of array types only; one constraint is that the array types must have identical representations. In GHC, The following pairs of array types have a non-copying O(1) implementation of 'unsafeThaw'. Because the optimised versions are enabled by specialisations, you will need to compile with optimisation (-O) to get them. * 'Data.Array.Unboxed.UArray' -> 'Data.Array.IO.IOUArray' * 'Data.Array.Unboxed.UArray' -> 'Data.Array.ST.STUArray' * 'Data.Array.Array' -> 'Data.Array.IO.IOArray' * 'Data.Array.Array' -> 'Data.Array.ST.STArray'-}{-# INLINE[1]unsafeThaw#-}unsafeThaw::(Ixi,IArrayae,MArraybem)=>aie->m(bie)unsafeThaw :: a i e -> m (b i e)unsafeThaw=a i e -> m (b i e)forall i (a :: * -> * -> *) e (b :: * -> * -> *) (m :: * -> *).(Ix i, IArray a e, MArray b e m) =>a i e -> m (b i e)thaw{-# INLINEunsafeThawSTUArray#-}unsafeThawSTUArray::UArrayie->STs(STUArraysie)unsafeThawSTUArray :: UArray i e -> ST s (STUArray s i e)unsafeThawSTUArray(UArrayl :: ilu :: iun :: Intnmarr# :: ByteArray#marr#)=STUArray s i e -> ST s (STUArray s i e)forall (m :: * -> *) a. Monad m => a -> m areturn(i -> i -> Int -> MutableByteArray# s -> STUArray s i eforall s i e.i -> i -> Int -> MutableByteArray# s -> STUArray s i eSTUArrayiliuIntn(ByteArray# -> MutableByteArray# sunsafeCoerce#ByteArray#marr#)){-# RULES"unsafeThaw/STArray"unsafeThaw=ArrST.unsafeThawSTArray"unsafeThaw/STUArray"unsafeThaw=unsafeThawSTUArray#-}{-# INLINEunsafeThawIOArray#-}unsafeThawIOArray::Arr.Arrayixe->IO(IOArrayixe)unsafeThawIOArray :: Array ix e -> IO (IOArray ix e)unsafeThawIOArrayarr :: Array ix earr=ST RealWorld (IOArray ix e) -> IO (IOArray ix e)forall a. ST RealWorld a -> IO astToIO(ST RealWorld (IOArray ix e) -> IO (IOArray ix e))-> ST RealWorld (IOArray ix e) -> IO (IOArray ix e)forall a b. (a -> b) -> a -> b$doSTArray RealWorld ix emarr<-Array ix e -> ST RealWorld (STArray RealWorld ix e)forall i e s. Array i e -> ST s (STArray s i e)ArrST.unsafeThawSTArrayArray ix earrIOArray ix e -> ST RealWorld (IOArray ix e)forall (m :: * -> *) a. Monad m => a -> m areturn(STArray RealWorld ix e -> IOArray ix eforall i e. STArray RealWorld i e -> IOArray i eIOArraySTArray RealWorld ix emarr){-# RULES"unsafeThaw/IOArray"unsafeThaw=unsafeThawIOArray#-}thawIOArray::Arr.Arrayixe->IO(IOArrayixe)thawIOArray :: Array ix e -> IO (IOArray ix e)thawIOArrayarr :: Array ix earr=ST RealWorld (IOArray ix e) -> IO (IOArray ix e)forall a. ST RealWorld a -> IO astToIO(ST RealWorld (IOArray ix e) -> IO (IOArray ix e))-> ST RealWorld (IOArray ix e) -> IO (IOArray ix e)forall a b. (a -> b) -> a -> b$doSTArray RealWorld ix emarr<-Array ix e -> ST RealWorld (STArray RealWorld ix e)forall i e s. Array i e -> ST s (STArray s i e)ArrST.thawSTArrayArray ix earrIOArray ix e -> ST RealWorld (IOArray ix e)forall (m :: * -> *) a. Monad m => a -> m areturn(STArray RealWorld ix e -> IOArray ix eforall i e. STArray RealWorld i e -> IOArray i eIOArraySTArray RealWorld ix emarr){-# RULES"thaw/IOArray"thaw=thawIOArray#-}freezeIOArray::IOArrayixe->IO(Arr.Arrayixe)freezeIOArray :: IOArray ix e -> IO (Array ix e)freezeIOArray(IOArraymarr :: STArray RealWorld ix emarr)=ST RealWorld (Array ix e) -> IO (Array ix e)forall a. ST RealWorld a -> IO astToIO(STArray RealWorld ix e -> ST RealWorld (Array ix e)forall s i e. STArray s i e -> ST s (Array i e)ArrST.freezeSTArraySTArray RealWorld ix emarr){-# RULES"freeze/IOArray"freeze=freezeIOArray#-}{-# INLINEunsafeFreezeIOArray#-}unsafeFreezeIOArray::IOArrayixe->IO(Arr.Arrayixe)unsafeFreezeIOArray :: IOArray ix e -> IO (Array ix e)unsafeFreezeIOArray(IOArraymarr :: STArray RealWorld ix emarr)=ST RealWorld (Array ix e) -> IO (Array ix e)forall a. ST RealWorld a -> IO astToIO(STArray RealWorld ix e -> ST RealWorld (Array ix e)forall s i e. STArray s i e -> ST s (Array i e)ArrST.unsafeFreezeSTArraySTArray RealWorld ix emarr){-# RULES"unsafeFreeze/IOArray"unsafeFreeze=unsafeFreezeIOArray#-}-- | Casts an 'STUArray' with one element type into one with a-- different element type. All the elements of the resulting array-- are undefined (unless you know what you\'re doing...).castSTUArray::STUArraysixa->STs(STUArraysixb)castSTUArray :: STUArray s ix a -> ST s (STUArray s ix b)castSTUArray(STUArrayl :: ixlu :: ixun :: Intnmarr# :: MutableByteArray# smarr#)=STUArray s ix b -> ST s (STUArray s ix b)forall (m :: * -> *) a. Monad m => a -> m areturn(ix -> ix -> Int -> MutableByteArray# s -> STUArray s ix bforall s i e.i -> i -> Int -> MutableByteArray# s -> STUArray s i eSTUArrayixlixuIntnMutableByteArray# smarr#)
[8]ページ先頭