souffle-haskell-1.0.0: 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.

pop :: MonadPop m => m a Source #

Unmarshals a value from the datalog side.

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

Marshals a value to the datalog side.

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

Unmarshals a value from the datalog side.

Instances
Marshal Int32 Source # 
Instance details

Defined in Language.Souffle.Marshal

Methods

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

pop :: MonadPop m => m Int32 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

pushInt :: Int32 -> m () Source #

Marshals an integer 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

popInt :: m Int32 Source #

Unmarshals an integer from the datalog side.

popString :: m String Source #

Unmarshals a string from the datalog side.