Copyright | (c) Alexey Kuleshevich 2021 |
---|---|
License | BSD3 |
Maintainer | Alexey Kuleshevich <alexey@kuleshevi.ch> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
This package provides instances for Persist
class for all mutable Array
representations in massiv
package. These
instances are provided as orphans from a separate package in order to avoid direct
dependency on persist
package in
massiv
.
Array elements are serialized in little endian order, which is consistent with the rest
of the instances in persist
package.
Below is a simple example how to use it. Note a blank module import: import
Massiv.Persist ()
, which is the only thing needed from this module in order to use
provided orphan instances.
>>>
import Massiv.Persist ()
>>>
import Data.Massiv.Array as A
>>>
import Data.Int (Int8)
>>>
let arr = A.fromList A.Seq [72,97,115,107,101,108,108] :: A.Vector A.P Int8
>>>
encode arr
"\NUL\a\NUL\NUL\NUL\NUL\NUL\NUL\NULHaskell">>>
Right arr' = decode (encode arr) :: Either String (A.Vector A.P Int8)
>>>
arr'
Array P Seq (Sz1 7) [ 72, 97, 115, 107, 101, 108, 108 ]
Synopsis
- putIx :: forall ix. Index ix => ix -> Put ()
- getIx :: forall ix. Index ix => Get ix
- mkSzFail :: forall ix m. (Index ix, MonadFail m) => ix -> m (Sz ix)
- putArray :: (Manifest r e, Index ix, Persist e) => Array r ix e -> Put ()
- getArray :: (Mutable r e, Index ix, Persist e) => Get (Array r ix e)
- putPrimArray :: forall ix e. (Index ix, Prim e, Persist e) => Array P ix e -> Put ()
- getPrimArray :: forall ix e. (Index ix, Prim e, Persist e) => Get (Array P ix e)
- putStorableArray :: forall ix e. (Index ix, Storable e, Persist e) => Array S ix e -> Put ()
- getStorableArray :: forall ix e. (Index ix, Storable e, Persist e) => Get (Array S ix e)
Helper functions used to define Persist instances
mkSzFail :: forall ix m. (Index ix, MonadFail m) => ix -> m (Sz ix) Source #
Construct size from index verifying its correctness.
Since: 0.1.0
putArray :: (Manifest r e, Index ix, Persist e) => Array r ix e -> Put () Source #
Serialize array as LittleEndian
Since: 0.1.0
getArray :: (Mutable r e, Index ix, Persist e) => Get (Array r ix e) Source #
Deserialize array from binary form in LittleEndian
Since: 0.1.0
putPrimArray :: forall ix e. (Index ix, Prim e, Persist e) => Array P ix e -> Put () Source #
Serialize primitive array in LittleEndian
order
Since: 0.1.0
getPrimArray :: forall ix e. (Index ix, Prim e, Persist e) => Get (Array P ix e) Source #
Deserialize primitive array in LittleEndian
order
Since: 0.1.0
putStorableArray :: forall ix e. (Index ix, Storable e, Persist e) => Array S ix e -> Put () Source #
Serialize storable array in LittleEndian
order
Since: 0.1.0
getStorableArray :: forall ix e. (Index ix, Storable e, Persist e) => Get (Array S ix e) Source #
Deserialize storable array in LittleEndian
order
Since: 0.1.0
Orphan instances
Persist Ix2 Source # | |
Persist Comp Source # | |
Index (IxN n) => Persist (IxN n) Source # | |
Index ix => Persist (Sz ix) Source # | |
(Index ix, Persist e) => Persist (Array BL ix e) Source # | |
(Index ix, Persist e) => Persist (Array B ix e) Source # | |
(Index ix, NFData e, Persist e) => Persist (Array BN ix e) Source # | |
(Index ix, Prim e, Persist e) => Persist (Array P ix e) Source # | |
(Index ix, Storable e, Persist e) => Persist (Array S ix e) Source # | |
(Index ix, Unbox e, Persist e) => Persist (Array U ix e) Source # | |