Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
An internal module, providing a slightly higher level interface than Language.Souffle.Internal.Bindings. It uses more commonly found data types instead of the low level C types for easier integration with other parts of a Haskell application. Also it takes care of garbage collection so other modules do not have to take this into account anymore.
Used only internally, so prone to changes, use at your own risk.
Synopsis
- data Souffle
- data Relation
- data RelationIterator
- data Tuple
- init :: String -> IO (Maybe (ForeignPtr Souffle))
- setNumThreads :: ForeignPtr Souffle -> Word64 -> IO ()
- getNumThreads :: ForeignPtr Souffle -> IO Word64
- run :: ForeignPtr Souffle -> IO ()
- loadAll :: ForeignPtr Souffle -> FilePath -> IO ()
- printAll :: ForeignPtr Souffle -> FilePath -> IO ()
- getRelation :: ForeignPtr Souffle -> String -> IO (Ptr Relation)
- countFacts :: Ptr Relation -> IO Int
- getRelationIterator :: Ptr Relation -> IO (ForeignPtr RelationIterator)
- relationIteratorNext :: ForeignPtr RelationIterator -> IO (Ptr Tuple)
- allocTuple :: Ptr Relation -> IO (ForeignPtr Tuple)
- addTuple :: Ptr Relation -> ForeignPtr Tuple -> IO ()
- containsTuple :: Ptr Relation -> ForeignPtr Tuple -> IO Bool
- tuplePushInt :: Ptr Tuple -> Int32 -> IO ()
- tuplePushString :: Ptr Tuple -> String -> IO ()
- tuplePopInt :: Ptr Tuple -> IO Int32
- tuplePopString :: Ptr Tuple -> IO String
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 :: String -> IO (Maybe (ForeignPtr 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 action will return Nothing
if it failed to load the Souffle program.
Otherwise it will return a pointer that can be used in other functions
in this module.
setNumThreads :: ForeignPtr Souffle -> Word64 -> IO () Source #
Sets the number of CPU cores this Souffle program should use.
getNumThreads :: ForeignPtr Souffle -> IO Word64 Source #
Gets the number of CPU cores this Souffle program should use.
loadAll :: ForeignPtr Souffle -> FilePath -> IO () Source #
Load all facts from files in a certain directory.
printAll :: ForeignPtr Souffle -> FilePath -> IO () Source #
Write out all facts of the program to CSV files in a certain directory (as defined in the Souffle program).
getRelation :: ForeignPtr Souffle -> String -> IO (Ptr Relation) Source #
Lookup a relation by name in the Souffle program.
Note that the returned pointer can be nullPtr
if it is not defined
in the Souffle program.
getRelationIterator :: Ptr Relation -> IO (ForeignPtr RelationIterator) Source #
Create an iterator for iterating over the facts of a relation.
relationIteratorNext :: ForeignPtr RelationIterator -> IO (Ptr Tuple) Source #
Advances the relation iterator by 1 position.
Calling this function when there are no more results to be returned will result in a crash.
allocTuple :: Ptr Relation -> IO (ForeignPtr Tuple) Source #
Allocates memory for a tuple (fact) to be added to a relation.
containsTuple :: Ptr Relation -> ForeignPtr Tuple -> IO Bool Source #
Checks if a relation contains a certain tuple.
Returns True if the tuple was found in the relation; otherwise False.