Hoogle Search

Within LTS Haskell 24.50 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. copySmallMutableArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> SmallMutableArray (PrimState m) a -> Int -> Int -> m ()

    primitive Data.Primitive.SmallArray

    Copy a slice of one mutable array into another. Note: this function does not do bounds or overlap checking.

  2. createSmallArray :: Int -> a -> (forall s . () => SmallMutableArray s a -> ST s ()) -> SmallArray a

    primitive Data.Primitive.SmallArray

    Create an array of the given size with a default value, apply the monadic function and freeze the result. If the size is 0, return emptySmallArray (rather than a new copy thereof).

    createSmallArray 0 _ _ = emptySmallArray
    createSmallArray n x f = runSmallArray $ do
    mary <- newSmallArray n x
    f mary
    pure mary
    

  3. emptySmallArray :: SmallArray a

    primitive Data.Primitive.SmallArray

    The empty SmallArray.

  4. freezeSmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> Int -> m (SmallArray a)

    primitive Data.Primitive.SmallArray

    Create an immutable array corresponding to a slice of a mutable array. This operation copies the portion of the array to be frozen. Note: The provided array should contain the full subrange specified by the two Ints, but this is not checked.

  5. getSizeofSmallMutableArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> m Int

    primitive Data.Primitive.SmallArray

    Get the number of elements in a mutable array. Unlike sizeofSmallMutableArray, this function will be sure to produce the correct result if SmallMutableArray has been shrunk in place. Consider the following:

    do
    sa <- newSmallArray 10 x
    print $ sizeofSmallMutableArray sa
    shrinkSmallMutableArray sa 5
    print $ sizeofSmallMutableArray sa
    
    The compiler is well within its rights to eliminate the second size check and print 10 twice. However, getSizeofSmallMutableArray will check the size each time it's executed (not evaluated), so it won't have this problem:
    do
    sa <- newSmallArray 10 x
    print =<< getSizeofSmallMutableArray sa
    shrinkSmallMutableArray sa 5
    print =<< getSizeofSmallMutableArray sa
    
    will certainly print 10 and then 5.

  6. indexSmallArray :: SmallArray a -> Int -> a

    primitive Data.Primitive.SmallArray

    Look up an element in an immutable array. Note: this function does not do bounds checking.

  7. indexSmallArray## :: SmallArray a -> Int -> (# a #)

    primitive Data.Primitive.SmallArray

    Read a value from the immutable array at the given index, returning the result in an unboxed unary tuple. This is currently used to implement folds. Note: this function does not do bounds checking.

  8. indexSmallArrayM :: Applicative m => SmallArray a -> Int -> m a

    primitive Data.Primitive.SmallArray

    Look up an element in an immutable array. The purpose of returning a result using an applicative is to allow the caller to avoid retaining references to the array. Evaluating the return value will cause the array lookup to be performed, even though it may not require the element of the array to be evaluated (which could throw an exception). For instance:

    data Box a = Box a
    ...
    
    f sa = case indexSmallArrayM sa 0 of
    Box x -> ...
    
    x is not a closure that references sa as it would be if we instead wrote:
    let x = indexSmallArray sa 0
    
    It also does not prevent sa from being garbage collected. Note that Identity is not adequate for this use, as it is a newtype, and cannot be evaluated without evaluating the element. Note: this function does not do bounds checking.

  9. mapSmallArray' :: (a -> b) -> SmallArray a -> SmallArray b

    primitive Data.Primitive.SmallArray

    Strict map over the elements of the array.

  10. newSmallArray :: PrimMonad m => Int -> a -> m (SmallMutableArray (PrimState m) a)

    primitive Data.Primitive.SmallArray

    Create a new small mutable array. Note: this function does not check if the input is non-negative.

Page 207 of many | Previous | Next