souffle-haskell-1.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 RelationIterator Source #

A void type, used for tagging a pointer that points to an iterator used for iterating over a relation.

data Tuple Source #

A void type, used for tagging a pointer that points to a tuple (term used in the Souffle compiler for a fact).

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.

getTupleCount :: Ptr Relation -> IO CSize Source #

Gets the amount of tuples found in a relation.

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++).

Returns the amount of tuples found in a relation.

getRelationIterator :: Ptr Relation -> IO (Ptr RelationIterator) Source #

Create an iterator for iterating over the facts of a relation.

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

The returned pointer needs to be freed with freeRelationIterator after it is no longer needed.

freeRelationIterator :: FunPtr (Ptr RelationIterator -> IO ()) Source #

Frees a pointer previously allocated with getRelationIterator.

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

relationIteratorNext :: Ptr RelationIterator -> IO (Ptr Tuple) Source #

Advances the relation iterator by 1 position.

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

Calling this function when there are no more tuples to be returned will result in a crash.

Returns a pointer to the next tuple. This pointer is not allowed to be freed as it is managed by the Souffle program already.

allocTuple :: Ptr Relation -> IO (Ptr Tuple) Source #

Allocates memory for a tuple (fact) to be added to a relation.

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

Returns a pointer to a new tuple. Use freeTuple when the tuple is no longer required.

freeTuple :: FunPtr (Ptr Tuple -> IO ()) Source #

Frees memory of a tuple that was previously allocated (in Haskell).

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

addTuple :: Ptr Relation -> Ptr Tuple -> IO () Source #

Adds a tuple to a relation.

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++).

containsTuple :: Ptr Relation -> Ptr Tuple -> 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.

tuplePushInt :: Ptr Tuple -> CInt -> IO () Source #

Pushes an integer value into a tuple.

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

Pushing an integer value onto a tuple that expects another type results in a crash. Pushing a value into a tuple when it already is "full" also results in a crash.

tuplePushString :: Ptr Tuple -> CString -> IO () Source #

Pushes a string value into a tuple.

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

Pushing a string value onto a tuple that expects another type results in a crash. Pushing a value into a tuple when it already is "full" also results in a crash.

tuplePopInt :: Ptr Tuple -> Ptr CInt -> IO () Source #

Extracts an integer value from a tuple.

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

Extracting an integer value from a tuple that expects another type results in a crash. Extracting a value from a tuple when it is already "empty" also results in a crash.

The popped integer will be stored in the pointer that is passed in.

tuplePopString :: Ptr Tuple -> Ptr CString -> IO () Source #

Extracts a string value from a tuple.

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

Extracting a string value from a tuple that expects another type results in a crash. Extracting a value from a tuple when it is already "empty" also results in a crash.

The popped string will be stored in the result pointer.