-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Unboxed, multidimensional arrays based on the primitive package. -- -- Provides unboxed multidimensional tables with a small interface. Comes -- with an instance for Ix keys. Read and Show instances are provides for -- serialization. @package PrimitiveArray @version 0.0.3.1 -- | Helper functions for creating new arrays. module Data.PrimitiveArray.Internal -- | Create a new m-array with a default value. newWith :: Prim a => Int -> a -> ST s (MutableByteArray s) -- | In new, z is not used. new :: Prim a => Int -> a -> ST s (MutableByteArray s) -- | Unboxed, primitive, multidimensional tables. In instance for -- Ix-type keys comes with the package. This package trades -- safety for speed. The index operator (!) is basically the only -- function that does bounds-checking and only with an assertion. This, -- however, is by design. The only way to get an immutable table from a -- mutable one is by the unsafeFreezeM operation. Again, it is by -- design that both data structures share the same memory pointer -- internally. -- -- TODO We kind-of lost all but the ST monad for monadic operations. module Data.PrimitiveArray class PrimArrayOps a b where { data family PrimArray a b :: *; } unsafeIndex :: PrimArrayOps a b => PrimArray a b -> a -> b assocs :: PrimArrayOps a b => PrimArray a b -> [(a, b)] fromAssocs :: PrimArrayOps a b => a -> a -> b -> [(a, b)] -> PrimArray a b bounds :: PrimArrayOps a b => PrimArray a b -> (a, a) checkBounds :: PrimArrayOps a b => PrimArray a b -> a -> Bool fromList :: PrimArrayOps a b => a -> a -> [b] -> PrimArray a b toList :: PrimArrayOps a b => PrimArray a b -> [b] class PrimMonad s => PrimArrayOpsM a b s where { data family PrimArrayM a b s :: *; } readM :: PrimArrayOpsM a b s => PrimArrayM a b s -> a -> s b writeM :: PrimArrayOpsM a b s => PrimArrayM a b s -> a -> b -> s () boundsM :: PrimArrayOpsM a b s => PrimArrayM a b s -> s (a, a) fromAssocsM :: PrimArrayOpsM a b s => a -> a -> b -> [(a, b)] -> s (PrimArrayM a b s) unsafeFreezeM :: PrimArrayOpsM a b s => PrimArrayM a b s -> s (PrimArray a b) fromListM :: PrimArrayOpsM a b s => a -> a -> [b] -> s (PrimArrayM a b s) toListM :: PrimArrayOpsM a b s => PrimArrayM a b s -> s [b] -- | Asserting unsafeIndex. Debug-code is checked for out-of-bounds -- occurances while production code uses unsafeIndex directly. (!) :: PrimArrayOps a b => PrimArray a b -> a -> b -- | Create a new array from an old one, mapping a function over all -- values. amap :: (PrimArrayOps a b, PrimArrayOps a c) => (b -> c) -> PrimArray a b -> PrimArray a c instance (Bounded a, Read a, Read b, PrimArrayOps a b) => Read (PrimArray a b) instance (Bounded a, Show a, Show b, PrimArrayOps a b) => Show (PrimArray a b) -- | PrimitiveArray with Ix keys. -- -- NOTE GHC 6.12.3 (and earlier, I guess) does not produce optimal code. -- Current head (6.13) produces very nice code. For example, -- unsafeIndex for 2-dim. tables with lower bound (0,0) produces -- one multiplication, one addition, one lookup, all using machine Int's. module Data.PrimitiveArray.Ix instance (Bounded a, Ix a, Prim b) => PrimArrayOpsM a b (ST s) instance (Bounded a, Ix a, Prim b) => PrimArrayOps a b