GHC.Data.SmallArray

ghc-lib-parser-9.14.1.20251220: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Data.SmallArray

Contents

- IO Operations

Description

Small-array

Synopsis

- data SmallMutableArray s a = SmallMutableArray (SmallMutableArray# s a)
- data SmallArray a = SmallArray (SmallArray# a)
- newSmallArray :: Int -> a -> State# s -> (# State# s, SmallMutableArray s a #)
- writeSmallArray :: SmallMutableArray s a -> Int -> a -> State# s -> State# s
- freezeSmallArray :: SmallMutableArray s a -> Int -> Int -> State# s -> (# State# s, SmallArray a #)
- unsafeFreezeSmallArray :: SmallMutableArray s a -> State# s -> (# State# s, SmallArray a #)
- indexSmallArray :: SmallArray a -> Int -> a
- sizeofSmallArray :: SmallArray a -> Int
- listToArray :: Int -> (e -> Int) -> (e -> a) -> [e] -> SmallArray a
- mapSmallArray :: (a -> b) -> SmallArray a -> SmallArray b
- foldMapSmallArray :: Monoid m => (a -> m) -> SmallArray a -> m
- rnfSmallArray :: NFData a => SmallArray a -> ()
- type SmallMutableArrayIO a = SmallMutableArray RealWorld a
- newSmallArrayIO :: Int -> a -> IO (SmallMutableArrayIO a)
- writeSmallArrayIO :: SmallMutableArrayIO a -> Int -> a -> IO ()
- unsafeFreezeSmallArrayIO :: SmallMutableArrayIO a -> IO (SmallArray a)

# Documentation

data SmallMutableArray s a #

Constructors

SmallMutableArray (SmallMutableArray# s a) |

data SmallArray a #

Constructors

SmallArray (SmallArray# a) |

newSmallArray #

Arguments

:: Int | size
-> a | initial contents
-> State# s |
-> (# State# s, SmallMutableArray s a #) |

writeSmallArray #

Arguments

:: SmallMutableArray s a | array
-> Int | index
-> a | new element
-> State# s |
-> State# s |

freezeSmallArray #

Arguments

:: SmallMutableArray s a | source
-> Int | offset
-> Int | length
-> State# s |
-> (# State# s, SmallArray a #) |

Copy and freeze a slice of a mutable array.

unsafeFreezeSmallArray :: SmallMutableArray s a -> State# s -> (# State# s, SmallArray a #) #

Freeze a mutable array (no copy!)

indexSmallArray #

Arguments

:: SmallArray a | array
-> Int | index
-> a |

Index a small-array (no bounds checking!)

sizeofSmallArray :: SmallArray a -> Int #

Get the size of a `SmallArray`

listToArray :: Int -> (e -> Int) -> (e -> a) -> [e] -> SmallArray a #

Convert a list into an array.

mapSmallArray :: (a -> b) -> SmallArray a -> SmallArray b #

Map a function over the elements of a `SmallArray`

foldMapSmallArray :: Monoid m => (a -> m) -> SmallArray a -> m #

Fold the values of a `SmallArray` into a 'Monoid m' of choice

rnfSmallArray :: NFData a => SmallArray a -> () #

Force the elements of the given `SmallArray`

# IO Operations

type SmallMutableArrayIO a = SmallMutableArray RealWorld a #

newSmallArrayIO :: Int -> a -> IO (SmallMutableArrayIO a) #

writeSmallArrayIO :: SmallMutableArrayIO a -> Int -> a -> IO () #

unsafeFreezeSmallArrayIO :: SmallMutableArrayIO a -> IO (SmallArray a) #