5(      !"#$%&'()*+,-./0123456789:;<=> ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \]^_`abcdefghijklmnopqrstuvwxyz{|}~ non-portable (concurrency) experimentallibraries@haskell.org 8Perform action while exclusively locking wrapped object  (faster analog of using  for the same purpose) /Define class of locking implementations, where lh holds lock around h 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 8Lift 1-parameter action to operation on locked variable 8Lift 2-parameter action to operation on locked variable 8Lift 3-parameter action to operation on locked variable 8Lift 4-parameter action to operation on locked variable 8Lift 5-parameter action to operation on locked variable GHC/Hugs experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com> portable experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>>Types that has default value >?>?Hugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>&\]^_`abcdefglmnopqrstuvwHugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>Modify the contents of an ! by applying pure function to it Write new value into an  Read the value of an  Modify the contents of an ' by applying monadic computation to it  Hugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>=&Additional operations on byte vectors %Alloc the mutable byte vector having elems elements of required type  == Hugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>3 !"#$%&'()*+,-./012345678GHC/Hugs experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>2unsafeFreezeDiffArray is really unsafe. Better don't use the old D array at all after freezing. The contents of the source array will  be changed when "$ is applied to the resulting array. )Fully polymorphic lazy boxed diff array. 5Strict unboxed diff array, working only for elements = of primitive types but more compact and usually faster than .  An arbitrary . type living in the  monad can be converted  to a diff array.  !"#$%&Hugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>HCreate new dynamic array where all new cells will remain uninitialized.  f" is a growing strategy and may be ,   or  "No automatic growing at all. This growing method is compatible with any  bounds type ACreate new dynamic array with default value for new cells set to .  f" is a growing strategy and may be ,   or  Dynamic arrays in IO monad Dynamic arrays in ST 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 UThis type represents function that calculates new array bounds when it needs to grow Extend/#shrink dynamic array to new bounds IGrow minimally - only to include new index in array bounds. This growing + method is compatible with any bounds type LGrow number of elements at least 2 times. This growing method is compatible ) only with bounds belonging to class Num Dynamic version of STUArray Dynamic version of STArray Dynamic version of IOUArray Dynamic version of IOArray "'()*+,-./012345678Hugs/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 . ()*+,-./012345678QZQZHugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>()*+,-./012345678.,7-/*834+012)5(6 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 5 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  55 internally, but this wrapper is a safe interface to  that function. ()*+,-./012345678P[P[GHC/Hugs experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>9The array type :1The pointer to the array contents is obtained by :.  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 :. ;2If you want to use it afterwards, ensure that you  ;$ after the last use of the pointer, & so the array is not freed too early. < Construct a 9 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:;<9:;< Hugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>1 !"#$%&'()*+,-./012345678PQSYZ[SQPYZ[GHC/Hugs experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>Freeze/thaw rules for STArray Freeze/thaw rules for IOArray  Instances !Boxed mutable arrays in ST monad !Boxed mutable arrays in IO monad Boxed immutable arrays Boxed mutable arrays Number of array elements GHC/Hugs experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com><Returns the contents of an array as a list of associations. BReturns the element of an immutable array at the specified index. +Class of array types with immutable bounds + (even if the array elements are mutable).  Extracts the bounds of an array  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. 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. 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. !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>'2Value used to initialize undefined array elements (-Converts an immutable array (any instance of  ) into a  mutable array (any instance of .) by taking a complete copy  of it. )*Converts a mutable array (any instance of .) to an " immutable array (any instance of ) by taking a complete  copy of it. *%Read an element from a mutable array +#Get the current bounds of an array ,)Class of array types with mutable bounds -ABuilds a new array, with every element initialised to undefined. .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. /<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. 04Return a list of all the indexes of a mutable array 15Return a list of all the elements of a mutable array 2=Return a list of all the associations of a mutable array, in  index order. 3EConstructs a new array derived from the original array by applying a # function to each of the elements. 4EConstructs a new array derived from the original array by applying a " function to each of the indices. 58Converts 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  51. 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 67Converts 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  61. 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 7CBuilds a new array, with every element initialised to the supplied  value. 8$Write an element in a mutable array '()*+,-./012345678 ',./01234)5(6 GHC/Hugs experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com> FFreeze/thaw rules for STUArray GFreeze/thaw rules for IOUArray P#Unboxed mutable arrays in ST monad Q#Unboxed mutable arrays in IO monad SUnboxed arrays TUnboxed mutable arrays WArray size in bytes Y,Casts to arrays with different element type  Casts an S  with one element type into S  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 Z Casts an Q  with one element type into Q  with a different - element type (upper bound is recalculated). [ Casts an P  with one element type into P  with a different - element type (upper bound is recalculated). @ABCDEFGHIJKLMNOPQRSTUVWXYZ[TPIQJSKOMNLUVRHWXGECAFDB@YZ[GHC/Hugs experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com> `hijk`hijkGHC/Hugs experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com> ^.Change value of unboxed reference in ST monad _4Read current value of unboxed reference in ST monad `Unboxed references in ST monad a.Change value of unboxed reference in IO monad b4Read current value of unboxed reference in IO monad cUnboxed references in IO monad d)Create new unboxed reference in IO monad eModify contents of an c! by applying pure function to it f)Create new unboxed reference in ST monad gModify contents of an `! by applying pure function to it \]^_`abcdefg c\dbae`]f_^gHugs/GHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com> lWrite new value into an n mRead the value of an n nKThis 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) oWrite new value into an q pRead the value of an q qIThis 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) rModify the contents of an q! by applying pure function to it sModify the contents of an q' by applying monadic computation to it tModify the contents of an n! by applying pure function to it uModify the contents of an n' by applying monadic computation to it v Create a new n with given initial value w Create a new q with given initial value lmnopqrstuvw qwporsnvmltuGHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com> y.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 xyz{|}~ yz{|}~xGHC experimental+Bulat Ziganshin <Bulat.Ziganshin@gmail.com>#Immutable and mutable byte vectors _Unboxed is like Storable, but values are stored in byte vectors (i.e. inside the Haskell heap) 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 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 KType functions which converts universal ST or IO types to IO-specific ones   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { |}~!pomn         #$ArrayRef-0.1.2 GHC.UnboxedControl.Monad.STorIO Data.UnboxedData.ArrayBZ.Internals.IArrayData.ArrayBZ.IArrayData.ArrayBZ.Internals.MArrayData.ArrayBZ.MArrayData.ArrayBZ.StorableData.HasDefaultValueData.ArrayBZ.Internals.UnboxedData.ArrayBZ.STData.ArrayBZ.IOData.ArrayBZ.UnboxedData.Ref.UnboxedData.Ref.LazySTData.Ref.Universal GHC.ArrBZData.ArrayBZ.Internals.BoxedData.ArrayBZ.BoxedData.ArrayBZ.DiffData.SyntaxSugarData.ArrayBZ.DynamicControl.Concurrent.LockingBZbaseControl.Concurrent.MVarData.RefPrelude Data.List Data.Word System.IOForeign.ForeignPtrData.IxfromI#mLiftUVecMUVecUnboxedSTorIOmemcpyallocUnboxedBytesunsafeFreezeUnboxedunsafeThawUnboxed freezeUnboxed thawUnboxed castUnboxed castMUnboxed readUnboxed writeUnboxed indexUnboxed sizeOfUnboxed IOSpecific3 IOSpecific2 IOSpecific cmpIntIArray cmpIArray showsIArrayassocs! HasBoundsboundsIArrayarray listArrayindiceselems accumArray//accumamapixmapeqIArray arrEleBottomthawfreeze readArray getBoundsHasMutableBounds newArray_MArray newListArray getIndicesgetElems getAssocsmapArray mapIndices unsafeFreeze unsafeThawnewArray writeArray StorableArraywithStorableArraytouchStorableArrayunsafeForeignPtrToStorableArray allocUnboxedHasDefaultValue defaultValueunsafeThawSTUArrayunsafeThawIOUArrayunsafeFreezeSTUArrayunsafeFreezeIOUArray thawSTUArray thawIOUArrayfreezeSTUArrayfreezeIOUArray unsafeThawUA stUArrayTc iOUArrayTcuArrayTcdoAccum withArrayCopy doReplace withNewArraySTUArrayIOUArrayunsafeFreezeUAUArrayUnboxedMutableArrayfreezeUAthawUAsizeOfUA sizeOfUMA castUArray castIOUArray castSTUArrayioURefTcstURefTc writeSTURef readSTURefSTURef writeIOURef readIOURefIOURef newIOURef modifyIOURef newSTURef modifySTURef writeURefreadURefURefwriteRefreadRefRef modifyRef modifyRefM modifyURef modifyURefMnewURefnewRefVecMVec allocBoxedunsafeFreezeBoxedunsafeThawBoxed freezeBoxed thawBoxed readBoxed writeBoxed indexBoxedunsafeThawSTArrayunsafeThawIOArrayunsafeFreezeSTArrayunsafeFreezeIOArray thawSTArray thawIOArray freezeSTArray freezeIOArray unsafeThawBA iOArrayTc stArrayTcSTArrayIOArrayunsafeFreezeBAArrayBoxedMutableArrayfreezeBAthawBAsizeOfBA readDiffArray newDiffArray DiffArray DiffUArrayreplaceDiffArray IOToDiffArray hGetArray hPutArray runSTArray runSTUArray modifyVarMutable modifyVarM hashUpdaterefurefval=:+=-=.=.<-newDynamicArray_noGrownewDynamicArray DynamicIO DynamicSTDynamic GrowBoundsFresizeDynamicArray growMinimally growTwoTimesDynamicSTUArrayDynamicSTArrayDynamicIOUArrayDynamicIOArray WithLockinglockLocking addLocking withLocking liftLock1 liftLock2 liftLock3 liftLock4 liftLock5withMVar Data.STRef modifySTRef Data.IORefatomicModifyIORef modifyIORef mkWeakIORef GHC.IOBase writeIORef readIORefnewIORefIORef GHC.STRef writeSTRef readSTRefnewSTRefSTRefwriteVarreadVarGHC.ArrIx rangeSizerangeinRangeindex unsafeAccum unsafeReplaceunsafeAccumArrayunsafeAt unsafeArray unsafeRead unsafeWriteunsafeFreezeDiffArrayIOGHC.ListinitGHC.WordWord8HandleGHC.ForeignPtr ForeignPtrBMABAUMAUAData.STRef.Lazy