Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Fixed size arrays
Intended for qualified import
import Data.FixedSizeArray (FixedSizeArray) import qualified Data.FixedSizeArray as FSA
Synopsis
- data FixedSizeArray (n :: Nat) (a :: Type)
- data MFixedSizeArray (n :: Nat) s (a :: Type)
- toArray :: FixedSizeArray n a -> Vector a
- toMArray :: MFixedSizeArray n s a -> MVector s a
- fromList :: forall n a. KnownNat n => [a] -> FixedSizeArray n a
- fromArray :: forall n a. KnownNat n => Vector a -> FixedSizeArray n a
- fromMArray :: forall n s a. KnownNat n => MVector s a -> MFixedSizeArray n s a
- new :: forall m n a. (PrimMonad m, KnownNat n) => m (MFixedSizeArray n (PrimState m) a)
Documentation
data FixedSizeArray (n :: Nat) (a :: Type) Source #
Fixed size arrays
FixedSizeArray n a
is the Haskell counter-part to the Rust type [A; N]
.
NOTE: For convenience, this is an instance of Vector
, but the invariant
that the length of the vector should never change is not currently checked.
Instances
data MFixedSizeArray (n :: Nat) s (a :: Type) Source #
Mutable fixed-size arrays
Instances
MVector (MFixedSizeArray n) a Source # | |
Defined in Data.FixedSizeArray basicLength :: MFixedSizeArray n s a -> Int # basicUnsafeSlice :: Int -> Int -> MFixedSizeArray n s a -> MFixedSizeArray n s a # basicOverlaps :: MFixedSizeArray n s a -> MFixedSizeArray n s a -> Bool # basicUnsafeNew :: Int -> ST s (MFixedSizeArray n s a) # basicInitialize :: MFixedSizeArray n s a -> ST s () # basicUnsafeReplicate :: Int -> a -> ST s (MFixedSizeArray n s a) # basicUnsafeRead :: MFixedSizeArray n s a -> Int -> ST s a # basicUnsafeWrite :: MFixedSizeArray n s a -> Int -> a -> ST s () # basicClear :: MFixedSizeArray n s a -> ST s () # basicSet :: MFixedSizeArray n s a -> a -> ST s () # basicUnsafeCopy :: MFixedSizeArray n s a -> MFixedSizeArray n s a -> ST s () # basicUnsafeMove :: MFixedSizeArray n s a -> MFixedSizeArray n s a -> ST s () # basicUnsafeGrow :: MFixedSizeArray n s a -> Int -> ST s (MFixedSizeArray n s a) # |
toArray :: FixedSizeArray n a -> Vector a Source #
toMArray :: MFixedSizeArray n s a -> MVector s a Source #
Construction
fromList :: forall n a. KnownNat n => [a] -> FixedSizeArray n a Source #
Construct FixedSizeArray
from list of unknown size
Throws an exception if the list does not have the right number of elements.
fromArray :: forall n a. KnownNat n => Vector a -> FixedSizeArray n a Source #
Construct FixedSizeArray
from array of unknown size
Throws an exception if the array does not have the right size.
fromMArray :: forall n s a. KnownNat n => MVector s a -> MFixedSizeArray n s a Source #
Construct FixedSizeArray
from mutable array of unknown size
Throws an exception if the array does not have the right size.