Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
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
- data Souffle
- data Relation
- data RelationIterator
- data Tuple
- init :: CString -> IO (Ptr Souffle)
- free :: FunPtr (Ptr Souffle -> IO ())
- setNumThreads :: Ptr Souffle -> CSize -> IO ()
- getNumThreads :: Ptr Souffle -> IO CSize
- run :: Ptr Souffle -> IO ()
- loadAll :: Ptr Souffle -> CString -> IO ()
- printAll :: Ptr Souffle -> CString -> IO ()
- getRelation :: Ptr Souffle -> CString -> IO (Ptr Relation)
- getTupleCount :: Ptr Relation -> IO CSize
- getRelationIterator :: Ptr Relation -> IO (Ptr RelationIterator)
- freeRelationIterator :: FunPtr (Ptr RelationIterator -> IO ())
- relationIteratorNext :: Ptr RelationIterator -> IO (Ptr Tuple)
- allocTuple :: Ptr Relation -> IO (Ptr Tuple)
- freeTuple :: FunPtr (Ptr Tuple -> IO ())
- addTuple :: Ptr Relation -> Ptr Tuple -> IO ()
- containsTuple :: Ptr Relation -> Ptr Tuple -> IO CBool
- tuplePushInt32 :: Ptr Tuple -> CInt -> IO ()
- tuplePushUInt32 :: Ptr Tuple -> CUInt -> IO ()
- tuplePushString :: Ptr Tuple -> CString -> IO ()
- tuplePushFloat :: Ptr Tuple -> CFloat -> IO ()
- tuplePopInt32 :: Ptr Tuple -> Ptr CInt -> IO ()
- tuplePopUInt32 :: Ptr Tuple -> Ptr CUInt -> IO ()
- tuplePopString :: Ptr Tuple -> Ptr CString -> IO ()
- tuplePopFloat :: Ptr Tuple -> Ptr CFloat -> IO ()
Documentation
A void type, used for tagging a pointer that points to an embedded Souffle program.
data RelationIterator Source #
A void type, used for tagging a pointer that points to an iterator used for iterating over a relation.
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.
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.
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.
tuplePushInt32 :: Ptr Tuple -> CInt -> IO () Source #
Pushes a 32 bit signed 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.
tuplePushUInt32 :: Ptr Tuple -> CUInt -> IO () Source #
Pushes a 32 bit unsigned 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.
tuplePushFloat :: Ptr Tuple -> CFloat -> IO () Source #
Pushes a float 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 float 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.
tuplePopInt32 :: Ptr Tuple -> Ptr CInt -> IO () Source #
Extracts a 32 bit signed 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.
tuplePopUInt32 :: Ptr Tuple -> Ptr CUInt -> IO () Source #
Extracts a 32 bit unsigned 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.
tuplePopFloat :: Ptr Tuple -> Ptr CFloat -> IO () Source #
Extracts a float 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 float 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 float will be stored in the pointer that is passed in.