primitive-unlifted-2.1.0.0: Primitive GHC types with unlifted types inside
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Primitive.TArray.Classic

Description

This module is a drop-in replacement for Control.Concurrent.STM.TArray in the stm package. It has the same fundamental inefficiency of the classic TArray, but it's a little faster and more compact. Specifically, this implementation uses two fewer words of memory and one fewer indirection per element. We also add an MArray instance for working in IO that the stm version lacks. Finally, the Eq instance for the official TArray is currently a little broken thanks to a bug in the instance for Data.Array.Array (See GHC Gitlab issue #18700). We fix that bug here.

Documentation

data TArray i a Source #

Instances

Instances details
MArray TArray e STM Source # 
Instance details

Defined in Data.Primitive.TArray.Classic

Methods

getBounds :: Ix i => TArray i e -> STM (i, i) #

getNumElements :: Ix i => TArray i e -> STM Int

newArray :: Ix i => (i, i) -> e -> STM (TArray i e) #

newArray_ :: Ix i => (i, i) -> STM (TArray i e) #

unsafeNewArray_ :: Ix i => (i, i) -> STM (TArray i e)

unsafeRead :: Ix i => TArray i e -> Int -> STM e

unsafeWrite :: Ix i => TArray i e -> Int -> e -> STM ()

MArray TArray e IO Source #

Writes are slow in IO.

Instance details

Defined in Data.Primitive.TArray.Classic

Methods

getBounds :: Ix i => TArray i e -> IO (i, i) #

getNumElements :: Ix i => TArray i e -> IO Int

newArray :: Ix i => (i, i) -> e -> IO (TArray i e) #

newArray_ :: Ix i => (i, i) -> IO (TArray i e) #

unsafeNewArray_ :: Ix i => (i, i) -> IO (TArray i e)

unsafeRead :: Ix i => TArray i e -> Int -> IO e

unsafeWrite :: Ix i => TArray i e -> Int -> e -> IO ()

Eq i => Eq (TArray i a) Source # 
Instance details

Defined in Data.Primitive.TArray.Classic

Methods

(==) :: TArray i a -> TArray i a -> Bool #

(/=) :: TArray i a -> TArray i a -> Bool #