souffle-haskell-2.0.1: Souffle Datalog bindings for Haskell
Safe HaskellNone
LanguageHaskell2010

Language.Souffle.Marshal

Description

This module exposes a uniform interface to marshal values to and from Souffle Datalog. This is done via the Marshal typeclass. Also, a mechanism is exposed for generically deriving marshalling and unmarshalling code for simple product types.

Synopsis

Documentation

class Marshal a where Source #

A typeclass for providing a uniform API to marshal/unmarshal values between Haskell and Souffle datalog.

The marshalling is done via a stack-based approach, where elements are pushed/popped one by one. You need to make sure that the marshalling of values happens in the correct order or unexpected things might happen (including crashes). Pushing and popping of fields should happen in the same order (from left to right, as defined in Datalog).

Generic implementations for push and pop that perform the previously described behavior are available. This makes it possible to write very succinct code:

data Edge = Edge String String deriving Generic

instance Marshal Edge

Minimal complete definition

Nothing

Methods

push :: MonadPush m => a -> m () Source #

Marshals a value to the datalog side.

default push :: (Generic a, SimpleProduct a, GMarshal (Rep a), MonadPush m) => a -> m () Source #

pop :: MonadPop m => m a Source #

Unmarshals a value from the datalog side.

default pop :: (Generic a, SimpleProduct a, GMarshal (Rep a), MonadPop m) => m a Source #

Instances

Instances details
Marshal Float Source # 
Instance details

Defined in Language.Souffle.Marshal

Methods

push :: MonadPush m => Float -> m () Source #

pop :: MonadPop m => m Float Source #

Marshal Int32 Source # 
Instance details

Defined in Language.Souffle.Marshal

Methods

push :: MonadPush m => Int32 -> m () Source #

pop :: MonadPop m => m Int32 Source #

Marshal Word32 Source # 
Instance details

Defined in Language.Souffle.Marshal

Methods

push :: MonadPush m => Word32 -> m () Source #

pop :: MonadPop m => m Word32 Source #

Marshal String Source # 
Instance details

Defined in Language.Souffle.Marshal

Methods

push :: MonadPush m => String -> m () Source #

pop :: MonadPop m => m String Source #

Marshal Text Source # 
Instance details

Defined in Language.Souffle.Marshal

Methods

push :: MonadPush m => Text -> m () Source #

pop :: MonadPop m => m Text Source #

Marshal Text Source # 
Instance details

Defined in Language.Souffle.Marshal

Methods

push :: MonadPush m => Text -> m () Source #

pop :: MonadPop m => m Text Source #

class Monad m => MonadPush m where Source #

A typeclass for serializing primitive values from Haskell to Datalog.

This typeclass is only used internally and subject to change.

See also: MonadPop, Marshal.

Methods

pushInt32 :: Int32 -> m () Source #

Marshals a signed 32 bit integer to the datalog side.

pushUInt32 :: Word32 -> m () Source #

Marshals an unsigned 32 bit integer to the datalog side.

pushFloat :: Float -> m () Source #

Marshals a float to the datalog side.

pushString :: String -> m () Source #

Marshals a string to the datalog side.

class Monad m => MonadPop m where Source #

A typeclass for serializing primitive values from Datalog to Haskell.

This typeclass is only used internally and subject to change.

See also: MonadPush, Marshal.

Methods

popInt32 :: m Int32 Source #

Unmarshals a signed 32 bir integer from the datalog side.

popUInt32 :: m Word32 Source #

Unmarshals an unsigned 32 bir integer from the datalog side.

popFloat :: m Float Source #

Unmarshals a float from the datalog side.

popString :: m String Source #

Unmarshals a string from the datalog side.