Currently, all messages are de/serialized via the Binary instance.
This is an implementation detail; there is strict required beyond the existence of two functions, encode :: a -> ByteString and decode :: ByteString -> Either String a. However, discussions in the DataHaskell group have raised the point that serialization for data science structures (e.g. dataframes) could be made more efficient by leveraging Parquet over the wire.
I'm thinking of an extension of the current Process monad, to support also a de/serialization strategy. This is strongly inspired by Servant's MimeRender and MimeUnrender classes. Consider:
newtype Process strategy a = Process ... -- Monad is unchanged, type has a new `strategy`
class Serialize strategy a where
encode :: Proxy strategy -> a -> ByteString
decode :: Proxy strategy -> ByteString -> Either String a
An example for JSON would be:
import Data.Aeson
data JSON
class (ToJSON a, FromJSON a) => Serialize JSON a where
encode _ = encode
decode _ = eitherDecodeStrict
Then, for the actual message sending e.g. via send, the type would become:
send :: Serialize strategy a => ProcessId -> a -> Process strategy ()
Then, programs that are agnostic of serialization are of type Process strategy a (instead of Process a), while programs which require a specific serialization method, such as JSON, will be of type Process JSON a.
Currently, all messages are de/serialized via the
Binaryinstance.This is an implementation detail; there is strict required beyond the existence of two functions,
encode :: a -> ByteStringanddecode :: ByteString -> Either String a. However, discussions in the DataHaskell group have raised the point that serialization for data science structures (e.g. dataframes) could be made more efficient by leveraging Parquet over the wire.I'm thinking of an extension of the current
Processmonad, to support also a de/serialization strategy. This is strongly inspired by Servant'sMimeRenderandMimeUnrenderclasses. Consider:An example for JSON would be:
Then, for the actual message sending e.g. via
send, the type would become:Then, programs that are agnostic of serialization are of type
Process strategy a(instead ofProcess a), while programs which require a specific serialization method, such as JSON, will be of typeProcess JSON a.