souffle-haskell-3.0.0: Souffle Datalog bindings for Haskell
Safe HaskellSafe
LanguageHaskell2010

Language.Souffle.Internal.Bindings

Description

This module provides C bindings exposed by the files in the cbits directory. This is an internal module, that is prone to have frequent changes, use at your own risk.

Synopsis

Documentation

data Souffle Source #

A void type, used for tagging a pointer that points to an embedded Souffle program.

data Relation Source #

A void type, used for tagging a pointer that points to a relation.

data ByteBuf Source #

A void type, used for tagging a pointer that points to a raw bytearray.

init :: CString -> IO (Ptr Souffle) Source #

Initializes a Souffle program.

The string argument is the name of the program and should be the same as the filename (minus the .dl extension). The pointer that is returned can be nullPtr in case something went wrong. If a valid pointer is returned, it needs to be freed by free after it is no longer needed.

free :: FunPtr (Ptr Souffle -> IO ()) Source #

Frees the memory in use by the pointer, previously allocated by init.

You need to check if the pointer is not equal to nullPtr before passing it to this function. Not doing so results in undefined behavior (in C++).

setNumThreads :: Ptr Souffle -> CSize -> IO () Source #

Sets the number of CPU cores this Souffle program should use.

You need to check if the pointer is not equal to nullPtr before passing it to this function. Not doing so results in undefined behavior (in C++).

getNumThreads :: Ptr Souffle -> IO CSize Source #

Gets the number of CPU cores this Souffle program should use.

You need to check if the pointer is equal to nullPtr before passing it to this function. Not doing so results in undefined behavior (in C++).

run :: Ptr Souffle -> IO () Source #

Runs the Souffle program.

You need to check if the pointer is equal to nullPtr before passing it to this function. Not doing so results in undefined behavior (in C++).

loadAll :: Ptr Souffle -> CString -> IO () Source #

Load all facts from files in a certain directory.

You need to check if both pointers are not equal to nullPtr before passing it to this function. Not doing so results in undefined behavior (in C++).

printAll :: Ptr Souffle -> CString -> IO () Source #

Write out all facts of the program to CSV files in a given directory (as defined in the Souffle program).

You need to check if the pointer is not equal to nullPtr before passing it to this function. Not doing so results in undefined behavior (in C++).

getRelation :: Ptr Souffle -> CString -> IO (Ptr Relation) Source #

Lookup a relation in the Souffle program.

You need to check if both passed pointers are not equal to nullPtr before passing it to this function. Not doing so results in undefined behavior (in C++).

The returned pointer can be nullPtr if the relation is not found. The pointer does not need to be freed, it is managed by the Souffle program.

pushByteBuf :: Ptr Relation -> Ptr ByteBuf -> CSize -> IO () Source #

Serializes many Datalog facts from Haskell to C++.

You need to check if the passed pointers are non-NULL before passing it to this function. Not doing so results in undefined behavior. Passing in a different count of objects to what is actually inside the byte buffer will crash.

popByteBuf :: Ptr Souffle -> Ptr Relation -> IO (Ptr ByteBuf) Source #

Serializes many Datalog facts from Datalog to Haskell

You need to check if the passed pointers are non-NULL before passing it to this function. Not doing so results in undefined behavior.

Returns a pointer to a byte buffer that contains the serialized Datalog facts.

containsTuple :: Ptr Relation -> Ptr ByteBuf -> IO CBool Source #

Checks if a relation contains a certain tuple.

You need to check if the passed pointers are non-NULL before passing it to this function. Not doing so results in undefined behavior.

Returns True if the tuple was found in the relation; otherwise False.