souffle-haskell-0.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 and MarshalT monad transformer. Also, a mechanism is exposed for generically deriving marshalling and unmarshalling code for simple product types.

Synopsis

Documentation

data MarshalT m a Source #

A monad transformer, used solely for marshalling and unmarshalling between Haskell and Souffle Datalog.

Instances

Instances details
MonadTrans MarshalT Source # 
Instance details

Defined in Language.Souffle.Marshal

Methods

lift :: Monad m => m a -> MarshalT m a #

MonadWriter w m => MonadWriter w (MarshalT m) Source # 
Instance details

Defined in Language.Souffle.Marshal

Methods

writer :: (a, w) -> MarshalT m a #

tell :: w -> MarshalT m () #

listen :: MarshalT m a -> MarshalT m (a, w) #

pass :: MarshalT m (a, w -> w) -> MarshalT m a #

MonadState s m => MonadState s (MarshalT m) Source # 
Instance details

Defined in Language.Souffle.Marshal

Methods

get :: MarshalT m s #

put :: s -> MarshalT m () #

state :: (s -> (a, s)) -> MarshalT m a #

MonadError e m => MonadError e (MarshalT m) Source # 
Instance details

Defined in Language.Souffle.Marshal

Methods

throwError :: e -> MarshalT m a #

catchError :: MarshalT m a -> (e -> MarshalT m a) -> MarshalT m a #

Monad m => Monad (MarshalT m) Source # 
Instance details

Defined in Language.Souffle.Marshal

Methods

(>>=) :: MarshalT m a -> (a -> MarshalT m b) -> MarshalT m b #

(>>) :: MarshalT m a -> MarshalT m b -> MarshalT m b #

return :: a -> MarshalT m a #

Functor m => Functor (MarshalT m) Source # 
Instance details

Defined in Language.Souffle.Marshal

Methods

fmap :: (a -> b) -> MarshalT m a -> MarshalT m b #

(<$) :: a -> MarshalT m b -> MarshalT m a #

Applicative m => Applicative (MarshalT m) Source # 
Instance details

Defined in Language.Souffle.Marshal

Methods

pure :: a -> MarshalT m a #

(<*>) :: MarshalT m (a -> b) -> MarshalT m a -> MarshalT m b #

liftA2 :: (a -> b -> c) -> MarshalT m a -> MarshalT m b -> MarshalT m c #

(*>) :: MarshalT m a -> MarshalT m b -> MarshalT m b #

(<*) :: MarshalT m a -> MarshalT m b -> MarshalT m a #

MonadIO m => MonadIO (MarshalT m) Source # 
Instance details

Defined in Language.Souffle.Marshal

Methods

liftIO :: IO a -> MarshalT m a #

runMarshalT :: MarshalT m a -> Tuple -> m a Source #

Execute the monad transformer and return the result. The tuple that is passed in will be used to marshal the data back and forth.

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. The programmer needs to make sure that the marshalling 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 :: MonadIO m => a -> MarshalT m () Source #

Marshals a value to the datalog side.

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

pop :: MonadIO m => MarshalT m a Source #

Unmarshals a value from the datalog side.

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

Instances

Instances details
Marshal Int32 Source # 
Instance details

Defined in Language.Souffle.Marshal

Methods

push :: forall (m :: Type -> Type). MonadIO m => Int32 -> MarshalT m () Source #

pop :: forall (m :: Type -> Type). MonadIO m => MarshalT m Int32 Source #

Marshal String Source # 
Instance details

Defined in Language.Souffle.Marshal

Methods

push :: forall (m :: Type -> Type). MonadIO m => String -> MarshalT m () Source #

pop :: forall (m :: Type -> Type). MonadIO m => MarshalT m String Source #