Copyright | (c) Alexey Kuleshevich 2018-2019 |
---|---|
License | BSD3 |
Maintainer | Alexey Kuleshevich <lehins@yandex.ru> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- class (Load r ix e, Source r ix e) => Manifest r ix e
- toManifest :: Manifest r ix e => Array r ix e -> Array M ix e
- data M
- data B = B
- data N = N
- data Uninitialized = Uninitialized
- unwrapArray :: Array B ix e -> Array e
- evalArray :: Comp -> Array e -> Array B Ix1 e
- unwrapMutableArray :: MArray s B ix e -> MutableArray s e
- evalMutableArray :: PrimMonad m => MutableArray (PrimState m) e -> m (MArray (PrimState m) B Ix1 e)
- unwrapNormalFormArray :: Array N ix e -> Array e
- evalNormalFormArray :: NFData e => Comp -> Array e -> Array N Ix1 e
- unwrapNormalFormMutableArray :: MArray s N ix e -> MutableArray s e
- evalNormalFormMutableArray :: (PrimMonad m, NFData e) => MutableArray (PrimState m) e -> m (MArray (PrimState m) N Ix1 e)
- data P = P
- class Prim a
- toByteArray :: Array P ix e -> ByteArray
- fromByteArray :: (Index ix, Prim e) => Comp -> Sz ix -> ByteArray -> Maybe (Array P ix e)
- fromByteArrayM :: (MonadThrow m, Index ix, Prim e) => Comp -> Sz ix -> ByteArray -> m (Array P ix e)
- toMutableByteArray :: MArray s P ix e -> MutableByteArray s
- fromMutableByteArray :: (Index ix, Prim e) => Sz ix -> MutableByteArray s -> Maybe (MArray s P ix e)
- fromMutableByteArrayM :: (MonadThrow m, Index ix, Prim e) => Sz ix -> MutableByteArray s -> m (MArray s P ix e)
- data S = S
- class Storable a
- toStorableVector :: Array S ix e -> Vector e
- toStorableMVector :: MArray s S ix e -> MVector s e
- withPtr :: (MonadUnliftIO m, Storable a) => MArray RealWorld S ix a -> (Ptr a -> m b) -> m b
- data U = U
- class (Vector Vector a, MVector MVector a) => Unbox a
- toUnboxedVector :: Array U ix e -> Vector e
- toUnboxedMVector :: MArray s U ix e -> MVector s e
- fromByteString :: Comp -> ByteString -> Array M Ix1 Word8
- castFromByteString :: Comp -> ByteString -> Array S Ix1 Word8
- toByteString :: Load r ix Word8 => Array r ix Word8 -> ByteString
- castToByteString :: Array S ix Word8 -> ByteString
- toBuilder :: Source r ix e => (e -> Builder) -> Array r ix e -> Builder
Manifest
class (Load r ix e, Source r ix e) => Manifest r ix e Source #
Manifest arrays are backed by actual memory and values are looked up versus
computed as it is with delayed arrays. Because of this fact indexing functions
(
, !
)(
, etc. are constrained to manifest arrays only.!?
)
Instances
Index ix => Manifest M ix e Source # | |
Defined in Data.Massiv.Array.Manifest.Internal | |
(Unbox e, Index ix) => Manifest U ix e Source # | |
Defined in Data.Massiv.Array.Manifest.Unboxed | |
(Index ix, Storable e) => Manifest S ix e Source # | |
Defined in Data.Massiv.Array.Manifest.Storable | |
(Index ix, Prim e) => Manifest P ix e Source # | |
Defined in Data.Massiv.Array.Manifest.Primitive | |
(Index ix, NFData e) => Manifest N ix e Source # | |
Defined in Data.Massiv.Array.Manifest.Boxed | |
Index ix => Manifest B ix e Source # | |
Defined in Data.Massiv.Array.Manifest.Boxed |
General Manifest representation
Instances
Boxed
Array representation for Boxed elements. This structure is element and spine strict, but elements are strict to Weak Head Normal Form (WHNF) only.
Instances
Array representation for Boxed elements. This structure is element and
spine strict, and elements are always in Normal Form (NF), therefore NFData
instance is required.
Instances
data Uninitialized Source #
An error that gets thrown when an unitialized element of a boxed array gets accessed. Can only
happen when array was constructed with unsafeNew
.
Instances
Show Uninitialized Source # | |
Defined in Data.Massiv.Core.Exception showsPrec :: Int -> Uninitialized -> ShowS # show :: Uninitialized -> String # showList :: [Uninitialized] -> ShowS # | |
Exception Uninitialized Source # | |
Defined in Data.Massiv.Core.Exception |
Conversion
Important part of all conversions in this section is that the actual boxed
Array
, which holds the pointers to values isn't copied around, it is always
kept as the same array. Conversion to Massiv boxed array will undergo evaluation during which
computation strategies will be respected.
O(n) - Wrap a boxed array and evaluate all elements to a WHNF.
Since: 0.2.1
unwrapMutableArray :: MArray s B ix e -> MutableArray s e Source #
O(1) - Unwrap mutable boxed array.
Since: 0.2.1
:: PrimMonad m | |
=> MutableArray (PrimState m) e | Mutable array that will get wrapped |
-> m (MArray (PrimState m) B Ix1 e) |
O(n) - Wrap mutable boxed array and evaluate all elements to WHNF.
Since: 0.2.1
unwrapNormalFormArray :: Array N ix e -> Array e Source #
O(1) - Unwrap a fully evaluated boxed array.
Since: 0.2.1
O(n) - Wrap a boxed array and evaluate all elements to a Normal Form (NF).
Since: 0.2.1
unwrapNormalFormMutableArray :: MArray s N ix e -> MutableArray s e Source #
O(1) - Unwrap a fully evaluated mutable boxed array.
Since: 0.2.1
evalNormalFormMutableArray :: (PrimMonad m, NFData e) => MutableArray (PrimState m) e -> m (MArray (PrimState m) N Ix1 e) Source #
O(n) - Wrap mutable boxed array and evaluate all elements to NF.
Since: 0.2.1
Primitive
Representation for Prim
itive elements
Instances
Class of types supporting primitive array operations
sizeOf#, alignment#, indexByteArray#, readByteArray#, writeByteArray#, setByteArray#, indexOffAddr#, readOffAddr#, writeOffAddr#, setOffAddr#
Instances
Conversion
fromByteArrayM :: (MonadThrow m, Index ix, Prim e) => Comp -> Sz ix -> ByteArray -> m (Array P ix e) Source #
toMutableByteArray :: MArray s P ix e -> MutableByteArray s Source #
O(1) - Extract the internal MutableByteArray
.
Since: 0.2.1
fromMutableByteArray :: (Index ix, Prim e) => Sz ix -> MutableByteArray s -> Maybe (MArray s P ix e) Source #
fromMutableByteArrayM :: (MonadThrow m, Index ix, Prim e) => Sz ix -> MutableByteArray s -> m (MArray s P ix e) Source #
O(1) - Construct a primitive mutable array from the MutableByteArray
. Will return Nothing
if number of elements doesn't match.
Since: 0.3.0
Storable
Representation for Storable
elements
Instances
The member functions of this class facilitate writing values of primitive types to raw memory (which may have been allocated with the above mentioned routines) and reading values from blocks of raw memory. The class, furthermore, includes support for computing the storage requirements and alignment restrictions of storable types.
Memory addresses are represented as values of type
, for some
Ptr
aa
which is an instance of class Storable
. The type argument to
Ptr
helps provide some valuable type safety in FFI code (you can't
mix pointers of different types without an explicit cast), while
helping the Haskell type system figure out which marshalling method is
needed for a given pointer.
All marshalling between Haskell and a foreign language ultimately
boils down to translating Haskell data structures into the binary
representation of a corresponding data structure of the foreign
language and vice versa. To code this marshalling in Haskell, it is
necessary to manipulate primitive data types stored in unstructured
memory blocks. The class Storable
facilitates this manipulation on
all types for which it is instantiated, which are the standard basic
types of Haskell, the fixed size Int
types (Int8
, Int16
,
Int32
, Int64
), the fixed size Word
types (Word8
, Word16
,
Word32
, Word64
), StablePtr
, all types from Foreign.C.Types,
as well as Ptr
.
sizeOf, alignment, (peek | peekElemOff | peekByteOff), (poke | pokeElemOff | pokeByteOff)
Instances
Conversion
toStorableVector :: Array S ix e -> Vector e Source #
O(1) - Unwrap storable array and pull out the underlying storable vector.
Since: 0.2.1
toStorableMVector :: MArray s S ix e -> MVector s e Source #
O(1) - Unwrap storable mutable array and pull out the underlying storable mutable vector.
Since: 0.2.1
Direct Pointer Access
withPtr :: (MonadUnliftIO m, Storable a) => MArray RealWorld S ix a -> (Ptr a -> m b) -> m b Source #
A pointer to the beginning of the mutable array.
Since: 0.1.3
Unboxed
Representation for Unbox
ed elements
Instances
class (Vector Vector a, MVector MVector a) => Unbox a #
Instances
Conversion
toUnboxedVector :: Array U ix e -> Vector e Source #
O(1) - Unwrap unboxed array and pull out the underlying unboxed vector.
Since: 0.2.1
toUnboxedMVector :: MArray s U ix e -> MVector s e Source #
O(1) - Unwrap unboxed mutable array and pull out the underlying unboxed mutable vector.
Since: 0.2.1
ByteString Conversion
O(1) - Convert a strict ByteString into a manifest array. Will return Nothing
if length
doesn't match the total number of elements of new array.
Since: 0.2.1
castFromByteString :: Comp -> ByteString -> Array S Ix1 Word8 Source #
O(1) - Cast a strict ByteString
into a S
torable array
Since: 0.3.0
:: Load r ix Word8 | |
=> Array r ix Word8 | Source array |
-> ByteString |
O(n) - Convert any source array into a strict ByteString
. In case when the source array is
actually storable, no memory copy will occur.
Since: 0.2.1
castToByteString :: Array S ix Word8 -> ByteString Source #
O(1) - Cast a S
torable array into a strict ByteString
Since: 0.3.0