!      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklm n o p q r s t u v w x y z { | } ~  GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>_Unboxed is like Storable, but values are stored in byte vectors (i.e. inside the Haskell heap) 1Read the value from mutable byte vector at given index 0Write the value to mutable byte vector at given index 3Read the value from immutable byte vector at given index 9How many bytes required to represent values of this type #Immutable and mutable byte vectors KType functions which converts universal ST or IO types to IO-specific ones That'-s all we need to unify ST and IO operations! Alloc the mutable byte vector 3Mutable->immutable byte vector on-place conversion 3Immutable->mutable byte vector on-place conversion IMutable->immutable byte vector conversion which takes a copy of contents IImmutable->mutable byte vector conversion which takes a copy of contents  Recast immutable unboxed vector Recast mutable unboxed vector      GHC/Hugs experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com> Class of immutable array types. An array type has the form (a i e) where a is the array type constructor (kind  * -> * -> *), i is the index type (a member of  the class ), and e is the element type. The IArray class is parameterised over both a and e#, so that instances specialised to &certain element types can be defined. +Class of array types with immutable bounds + (even if the array elements are mutable).  Extracts the bounds of an array BConstructs an immutable array from a pair of bounds and a list of initial associations. GThe bounds are specified as a pair of the lowest and highest bounds in Gthe array respectively. For example, a one-origin vector of length 10 ?has bounds (1,10), and a one-origin 10 by 10 matrix has bounds ((1,1),(10,10)). %An association is a pair of the form (i,x), which defines the value of the array at index i to be x'. The array is undefined if any index Hin the list is out of bounds. If any two associations in the list have Ethe same index, the value at that index is implementation-dependent. :(In GHC, the last value specified for that index is used. HOther implementations will also do this for unboxed arrays, but Haskell 98 requires that for Array' the value at such indices is bottom.) 6Because the indices must be checked for these errors,  is Dstrict in the bounds argument and in the indices of the association list. Whether array1 is strict or non-strict in the elements depends on the array type: Data.Array.Array! is a non-strict array type, but  all of the Data.Array.Unboxed.UArray arrays are strict. Thus in a Bnon-strict array, recurrences such as the following are possible:  A a = array (1,100) ((1,1) : [(i, i * a!(i-1)) | i \<- [2..100]]) BNot every index within the bounds of the array need appear in the Eassociation list, but the values associated with indices that do not appear will be undefined. GIf, in any dimension, the lower bound is greater than the upper bound, Cthen the array is legal, but empty. Indexing an empty array always !gives an array-bounds error, but  still yields the bounds with !which the array was constructed. ?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. !BReturns the element of an immutable array at the specified index. "5Returns a list of all the valid indices in an array. #BReturns a list of all the elements of an array, in the same order  as their indices. $<Returns the contents of an array as a list of associations. %CConstructs an immutable array from a list of associations. Unlike @, the same index is allowed to occur multiple times in the list of associations; an accumulating function is used to combine the (values of elements with the same index. FFor example, given a list of values of some index type, hist produces @a histogram of the number of occurrences of each index within a specified range: 4 hist :: (Ix a, Num b) => (a,a) -> [a] -> Array a b H hist bnds is = accumArray (+) 0 bnds [(i, 1) | i\<-is, inRange bnds i] &ETakes an array and a list of pairs and returns an array identical to Fthe left argument except that it has been updated by the associations Hin the right argument. For example, if m is a 1-origin, n by n matrix, then m//[((i,i), 0) | i <- [1..n]]! is the same matrix, except with the diagonal zeroed.  As with the 4 function, if any two associations in the list have Ethe same index, the value at that index is implementation-dependent. :(In GHC, the last value specified for that index is used. HOther implementations will also do this for unboxed arrays, but Haskell 98 requires that for Array' the value at such indices is bottom.) *For most array types, this operation is O(n) where n is the size of the array. However, the Data.Array.Diff.DiffArray type provides @this operation with complexity linear in the number of updates. 'accum f> takes an array and an association list and accumulates pairs <from the list into the array with the accumulating function f. Thus % can be defined using ': ? accumArray f z b = accum f (array b [(i, z) | i \<- range b]) (BReturns a new array derived from the original array by applying a # function to each of the elements. )BReturns a new array derived from the original array by applying a " function to each of the indices.  !"#$%&'()*+,- !"#$%&'()*+,- !"#$%&'()*+,-GHC/Hugs experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>.Class of mutable array types. An array type has the form (a i e) where a is the array type constructor (kind  * -> * -> *), i is the index type (a member of  the class ), and e is the element type. The MArray" class is parameterised over both a and e (so that Finstances specialised to certain element types can be defined, in the same way as for (), and also over the type of the monad, m, 0in which the mutable array will be manipulated. /CBuilds a new array, with every element initialised to the supplied  value. 0ABuilds a new array, with every element initialised to undefined. 5)Class of array types with mutable bounds 6#Get the current bounds of an array 72Value used to initialize undefined array elements 8<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. 94Return a list of all the indexes of a mutable array :5Return a list of all the elements of a mutable array ;=Return a list of all the associations of a mutable array, in  index order. <EConstructs a new array derived from the original array by applying a # function to each of the elements. =EConstructs a new array derived from the original array by applying a " function to each of the indices. >*Converts a mutable array (any instance of .) to an " immutable array (any instance of ) by taking a complete  copy of it. ?8Converts an mutable array into an immutable array. The 8 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. CNote that because the array is possibly not copied, any subsequent A modifications made to the mutable version of the array may be H shared with the immutable version. It is safe to use, therefore, if E the mutable version is never modified after the freeze operation. BThe non-copying implementation is supported between certain pairs D of array types only; one constraint is that the array types must C have identical representations. In GHC, The following pairs of 9 array types have a non-copying O(1) implementation of  ?1. Because the optimised versions are enabled by G 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 @-Converts an immutable array (any instance of  ) into a  mutable array (any instance of .) by taking a complete copy  of it. A7Converts an immutable array into a mutable array. The 8 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. CNote that because the array is possibly not copied, any subsequent A modifications made to the mutable version of the array may be ? shared with the immutable version. It is only safe to use, G therefore, if the immutable array is never referenced again in this F thread, and there is no possibility that it can be also referenced / in another thread. If you use an unsafeThawwrite unsafeFreeze C sequence in a multi-threaded setting, then you must ensure that G this sequence is atomic with respect to other threads, or a garbage E collector crash may result (because the write may be writing to a  frozen array). BThe non-copying implementation is supported between certain pairs D of array types only; one constraint is that the array types must C have identical representations. In GHC, The following pairs of 9 array types have a non-copying O(1) implementation of  A1. Because the optimised versions are enabled by G 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 ./0123456789:;<=>?@A756./0123489:;<=>?@A./01234/01234566789:;<=>?@AGHC/Hugs experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>BThe array type C1The pointer to the array contents is obtained by C.  The idea is similar to  (used internally here). 9 The pointer should be used only during execution of the  action / retured by the function passed as argument to C. D2If you want to use it afterwards, ensure that you  D$ after the last use of the pointer, & so the array is not freed too early. E Construct a B from an arbitrary  . It is  the caller'$s responsibility to ensure that the  points to 8 an area of memory sufficient for the specified bounds. ./0123456789:;<=>?@ABCDEBCDEBCDEHugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>"./0345689:;<=>?@A./034568<="9:;>?@AHugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>F&Additional operations on byte vectors %Alloc the mutable byte vector having elems elements of required type FFFportable experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>GTypes that has default value GHGHGHHGHC/Hugs experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>   GHC/Hugs experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com> IUnboxed arrays K#Unboxed mutable arrays in IO monad L#Unboxed mutable arrays in ST monad MUnboxed mutable arrays RArray size in bytes TFreeze/thaw rules for IOUArray XFreeze/thaw rules for STUArray \,Casts to arrays with different element type  Casts an I with one element type into I with a A different element type. All the elements of the resulting array ( are undefined (unless you know what you're doing...). ? Upper array bound is recalculated according to elements size, 7 for example UArray (1,2) Word32 -> UArray (1,8) Word8 ] Casts an K with one element type into K with a different - element type (upper bound is recalculated). ^ Casts an L with one element type into L with a different - element type (upper bound is recalculated). IJKLMNOPQRSTUVWXYZ[\]^MNLOKPIJQRSTUVWXYZ[\]^IJJKLMNNOPQRSTUVWXYZ[\]^Hugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>1 !"#$%&'()*+,-./0123456789:;<=>?@AIKL\]^IKL\]^GHC/Hugs experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com> _Unboxed references in ST monad aUnboxed references in IO monad d)Create new unboxed reference in IO monad e4Read current value of unboxed reference in IO monad f.Change value of unboxed reference in IO monad gModify contents of an ba! by applying pure function to it i)Create new unboxed reference in ST monad j4Read current value of unboxed reference in ST monad k.Change value of unboxed reference in ST monad lModify contents of an `_! by applying pure function to it _`abcdefghijklabcdefg_`hijkl_``abbcdefghijkl GHC/Hugs experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com> _mnop_mnopmnop Hugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>qModify the contents of an u ! by applying pure function to it Modify the contents of an u ' by applying monadic computation to it KThis class allows to create new unboxed reference in monad-independent way K (suitable for writing code that will work in IO, ST and other monads) r Create a new q  with given initial value sRead the value of an q  tWrite new value into an q  uIThis class allows to create new boxed reference in monad-independent way K (suitable for writing code that will work in IO, ST and other monads) v Create a new u  with given initial value wRead the value of an u  xWrite new value into an u  qrstuvwxuvwxqrstqrstrstuvwxvwxHugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>&_`abcdefghijklqrstuvwx GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com> {.Immutable and mutable vectors of boxed values }Alloc the mutable vector ~.Mutable->immutable vector on-place conversion .Immutable->mutable vector on-place conversion DMutable->immutable vector conversion which takes a copy of contents DImmutable->mutable vector conversion which takes a copy of contents ,Read the value from mutable vector at given index +Write the value to mutable vector at given index .Read the value from immutable vector at given index yz{|}~ {|yz}~ yzz{||}~ GHC/Hugs experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>Boxed immutable arrays !Boxed mutable arrays in IO monad !Boxed mutable arrays in ST monad Boxed mutable arrays Number of array elements Freeze/thaw rules for IOArray Freeze/thaw rules for STArray Hugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>3 !"#$%&'()*+,-./0123456789:;<=>?@A GHC/Hugs experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>5Strict unboxed diff array, working only for elements = of primitive types but more compact and usually faster than  . )Fully polymorphic lazy boxed diff array.  An arbitrary . type living in the  monad can be converted  to a diff array.  !"#$%&'()*+,-Hugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com> !"#$%&'() %!"#$&'()Hugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>Reads a number of s from the specified  directly  into an array. Writes an array of  to the specified . "./0345689:;<=>?@AK]K]Hugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>GA safe way to create and work with a mutable array before returning an B immutable array for later perusal. This function avoids copying ) the array before returning it - it uses ? internally, but 4 this wrapper is a safe interface to that function. CA safe way to create and work with an unboxed mutable array before @ returning an immutable array for later perusal. This function 8 avoids copying the array before returning it - it uses  ?5 internally, but this wrapper is a safe interface to  that function. "./0345689:;<=>?@AL^L^Hugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>Read the value of an  Write new value into an  Hugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>UThis type represents function that calculates new array bounds when it needs to grow Dynamic version of STUArray Dynamic version of STArray Dynamic arrays in ST monad Dynamic version of IOUArray Dynamic version of IOArray Dynamic arrays in IO monad *Representation of dynamic array. Includes D * function to calculate new array bounds when it needs to grow J * optional value used for initializing new elements when array grows + * reference to current array contents "./0123456789:;<=>?@Anon-portable (concurrency) experimentallibraries@haskell.org/Define class of locking implementations, where lh holds lock around h 8Perform action while exclusively locking wrapped object  (faster analog of using  for the same purpose) 7Type constructor that attaches lock to immutable value h Add lock to object to ensure it'#s proper use in concurrent threads Run action with locked version of object  !"#$%%&&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{||}}~       3             ArrayRef-0.1 GHC.UnboxedData.ArrayBZ.Internals.IArrayData.ArrayBZ.Internals.MArrayData.ArrayBZ.Storable Data.UnboxedData.HasDefaultValueData.ArrayBZ.Internals.UnboxedData.Ref.UnboxedData.Ref.LazySTData.Ref.Universal GHC.ArrBZData.ArrayBZ.Internals.BoxedData.ArrayBZ.DiffData.ArrayBZ.IOData.ArrayBZ.STData.SyntaxSugarData.ArrayBZ.DynamicControl.Concurrent.LockingBZbaseGHC.ArrForeign.ForeignPtr System.IOData.ArrayBZ.MArrayControl.Monad.STorIOData.ArrayBZ.UnboxedData.RefData.ArrayBZ.BoxedData.ArrayBZ.IArray Data.WordControl.Concurrent.MVarmemcpyUnboxed readUnboxed writeUnboxed indexUnboxed sizeOfUnboxedMUVecUVec IOSpecific3 IOSpecific2 IOSpecificSTorIOmLiftallocUnboxedBytesunsafeFreezeUnboxedunsafeThawUnboxed freezeUnboxed thawUnboxed castUnboxed castMUnboxedfromI#IArray unsafeArrayunsafeAt unsafeReplace unsafeAccumunsafeAccumArray HasBoundsboundsarray listArray!indiceselemsassocs accumArray//accumamapixmap showsIArrayeqIArray cmpIArray cmpIntIArrayMArraynewArray newArray_ unsafeRead unsafeWrite readArray writeArrayHasMutableBounds getBounds arrEleBottom newListArray getIndicesgetElems getAssocsmapArray mapIndicesfreeze unsafeFreezethaw unsafeThaw StorableArraywithStorableArraytouchStorableArrayunsafeForeignPtrToStorableArray allocUnboxedHasDefaultValue defaultValueUArrayUAIOUArraySTUArrayUnboxedMutableArrayUMA stUArrayTc iOUArrayTcuArrayTcsizeOfUA sizeOfUMAfreezeIOUArray thawIOUArrayunsafeFreezeIOUArrayunsafeThawIOUArrayfreezeSTUArray thawSTUArrayunsafeFreezeSTUArrayunsafeThawSTUArray castUArray castIOUArray castSTUArraySTURefIOURefioURefTc newIOURef readIOURef writeIOURef modifyIOURefstURefTc newSTURef readSTURef writeSTURef modifySTURefURefnewURefreadURef writeURefRefnewRefreadRefwriteRefMVecVec allocBoxedunsafeFreezeBoxedunsafeThawBoxed freezeBoxed thawBoxed readBoxed writeBoxed indexBoxedArrayBAIOArraySTArrayBoxedMutableArrayBMA freezeIOArray thawIOArrayunsafeFreezeIOArrayunsafeThawIOArray freezeSTArray thawSTArrayunsafeFreezeSTArrayunsafeThawSTArray iOArrayTc stArrayTc DiffUArray DiffArray IOToDiffArray newDiffArray readDiffArrayreplaceDiffArray hGetArray hPutArray runSTArray runSTUArrayMutablereadVarwriteVar GrowBoundsFDynamicSTUArrayDynamicSTArray DynamicSTDynamicIOUArrayDynamicIOArray DynamicIODynamicLockinglock WithLocking addLocking withLockingIxGHC.ForeignPtr ForeignPtr GHC.IOBaseIO rangeSizeinRangeindexrange withNewArray withArrayCopy doReplacedoAccumfreezeUAthawUAunsafeFreezeUA unsafeThawUAData.STRef.Lazy modifySTRef writeSTRef readSTRefnewSTRef GHC.STRefSTRef modifyRef modifyRefM modifyURef modifyURefM Data.STRef Data.IORefatomicModifyIORef modifyIORef mkWeakIORef writeIORef readIORefnewIORefIOReffreezeBAthawBAunsafeFreezeBA unsafeThawBAsizeOfBAGHC.WordWord8Handle modifyVar modifyVarM hashUpdaterefurefval=:+=-=.=.<-newDynamicArraynewDynamicArray_resizeDynamicArraynoGrow growMinimally growTwoTimeswithMVar liftLock1 liftLock2 liftLock3 liftLock4 liftLock5