massiv-persist-1.0.0.2: Compatibility of 'massiv' with 'persist'
Copyright(c) Alexey Kuleshevich 2021
LicenseBSD3
MaintainerAlexey Kuleshevich <alexey@kuleshevi.ch>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Massiv.Persist

Description

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

Helper functions used to define Persist instances

putIx :: forall ix. Index ix => ix -> Put () Source #

Encode index

Since: 0.1.0

getIx :: forall ix. Index ix => Get ix Source #

Decode index

Since: 0.1.0

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 # 
Instance details

Methods

put :: Ix2 -> Put () #

get :: Get Ix2 #

Persist Comp Source # 
Instance details

Methods

put :: Comp -> Put () #

get :: Get Comp #

Index (IxN n) => Persist (IxN n) Source # 
Instance details

Methods

put :: IxN n -> Put () #

get :: Get (IxN n) #

Index ix => Persist (Sz ix) Source # 
Instance details

Methods

put :: Sz ix -> Put () #

get :: Get (Sz ix) #

(Index ix, Persist e) => Persist (Array BL ix e) Source # 
Instance details

Methods

put :: Array BL ix e -> Put () #

get :: Get (Array BL ix e) #

(Index ix, Persist e) => Persist (Array B ix e) Source # 
Instance details

Methods

put :: Array B ix e -> Put () #

get :: Get (Array B ix e) #

(Index ix, NFData e, Persist e) => Persist (Array BN ix e) Source # 
Instance details

Methods

put :: Array BN ix e -> Put () #

get :: Get (Array BN ix e) #

(Index ix, Prim e, Persist e) => Persist (Array P ix e) Source # 
Instance details

Methods

put :: Array P ix e -> Put () #

get :: Get (Array P ix e) #

(Index ix, Storable e, Persist e) => Persist (Array S ix e) Source # 
Instance details

Methods

put :: Array S ix e -> Put () #

get :: Get (Array S ix e) #

(Index ix, Unbox e, Persist e) => Persist (Array U ix e) Source # 
Instance details

Methods

put :: Array U ix e -> Put () #

get :: Get (Array U ix e) #