Maintainer | defanor <defanor@uberspace.net> |
---|---|
Stability | unstable |
Portability | non-portable (GHC extensions are used) |
Safe Haskell | Safe |
Language | Haskell2010 |
Mid-level Redland RDF library
bindings: using Haskell naming conventions, common Haskell types,
ForeignPtr
with finalizers, exceptions, copied structures (as
opposed to the shared ones, as nodes in statement-related functions in
the C API). Closely follows the original API otherwise.
- data RedlandException
- type Initializer a = IO (ForeignPtr a)
- initialize :: IO (Ptr a) -> FinalizerPtr a -> Initializer a
- perform :: IO CInt -> IO ()
- withNew :: Initializer a -> (ForeignPtr a -> IO b) -> IO b
- withNullablePtr :: (a -> (Ptr b -> c) -> c) -> Maybe a -> (Ptr b -> c) -> c
- maybeCString :: CString -> IO (Maybe String)
- maybeSharedCString :: CString -> IO (Maybe String)
- justCString :: CString -> IO String
- justSharedCString :: CString -> IO String
- redlandWorld :: Initializer RedlandWorld
- redlandHash :: ForeignPtr RedlandWorld -> String -> Initializer RedlandHash
- hashPutStrings :: ForeignPtr RedlandHash -> String -> String -> IO ()
- hashGet :: ForeignPtr RedlandHash -> String -> IO (Maybe String)
- hashGetDel :: ForeignPtr RedlandHash -> String -> IO (Maybe String)
- redlandModel :: ForeignPtr RedlandWorld -> ForeignPtr RedlandStorage -> String -> Initializer RedlandModel
- modelQueryExecute :: ForeignPtr RedlandModel -> ForeignPtr RedlandQuery -> Initializer RedlandQueryResults
- modelFindStatements :: ForeignPtr RedlandModel -> ForeignPtr RedlandStatement -> Initializer RedlandStream
- modelSync :: ForeignPtr RedlandModel -> IO ()
- modelLoad :: ForeignPtr RedlandModel -> ForeignPtr RedlandURI -> Maybe String -> Maybe String -> Maybe (ForeignPtr RedlandURI) -> IO ()
- redlandNode :: ForeignPtr RedlandWorld -> Initializer RedlandNode
- nodeFromNode :: ForeignPtr RedlandNode -> Initializer RedlandNode
- nodeFromBlankIdentifier :: ForeignPtr RedlandWorld -> Maybe String -> Initializer RedlandNode
- nodeFromLiteral :: ForeignPtr RedlandWorld -> String -> Maybe String -> Bool -> Initializer RedlandNode
- nodeFromTypedLiteral :: ForeignPtr RedlandWorld -> String -> Maybe String -> Maybe (ForeignPtr RedlandURI) -> Initializer RedlandNode
- nodeFromURI :: ForeignPtr RedlandWorld -> ForeignPtr RedlandURI -> Initializer RedlandNode
- nodeFromURIString :: ForeignPtr RedlandWorld -> String -> Initializer RedlandNode
- nodeGetBlankIdentifier :: ForeignPtr RedlandNode -> IO String
- nodeGetLiteralValue :: ForeignPtr RedlandNode -> IO String
- nodeGetLiteralValueLanguage :: ForeignPtr RedlandNode -> IO (Maybe String)
- nodeGetLiteralValueDatatypeURI :: ForeignPtr RedlandNode -> IO (Maybe (ForeignPtr RedlandURI))
- nodeGetLiteralValueIsWellFormedXML :: ForeignPtr RedlandNode -> IO Bool
- nodeGetURI :: ForeignPtr RedlandNode -> Initializer RedlandURI
- nodeIsBlank :: ForeignPtr RedlandNode -> IO Bool
- nodeIsLiteral :: ForeignPtr RedlandNode -> IO Bool
- nodeIsResource :: ForeignPtr RedlandNode -> IO Bool
- nodeToString :: ForeignPtr RedlandNode -> IO String
- redlandParser :: ForeignPtr RedlandWorld -> Maybe String -> Maybe String -> Maybe (ForeignPtr RedlandURI) -> Initializer RedlandParser
- parseStringIntoModel :: ForeignPtr RedlandParser -> String -> ForeignPtr RedlandURI -> ForeignPtr RedlandModel -> IO ()
- parserGuessName2 :: ForeignPtr RedlandWorld -> Maybe String -> Maybe String -> Maybe String -> IO (Maybe String)
- redlandQuery :: ForeignPtr RedlandWorld -> String -> Maybe (ForeignPtr RedlandURI) -> String -> Maybe (ForeignPtr RedlandURI) -> Initializer RedlandQuery
- queryResultsGetCount :: ForeignPtr RedlandQueryResults -> IO Int
- queryResultsNext :: ForeignPtr RedlandQueryResults -> IO Bool
- queryResultsFinished :: ForeignPtr RedlandQueryResults -> IO Bool
- queryResultsGetBindingValue :: ForeignPtr RedlandQueryResults -> Int -> Initializer RedlandNode
- queryResultsGetBindingName :: ForeignPtr RedlandQueryResults -> Int -> IO String
- queryResultsGetBindingValueByName :: ForeignPtr RedlandQueryResults -> String -> Initializer RedlandNode
- queryResultsGetBindingsCount :: ForeignPtr RedlandQueryResults -> IO Int
- queryExecute :: ForeignPtr RedlandQuery -> ForeignPtr RedlandModel -> Initializer RedlandQueryResults
- redlandStatement :: ForeignPtr RedlandWorld -> Initializer RedlandStatement
- statementFromNodes :: ForeignPtr RedlandWorld -> Maybe (ForeignPtr RedlandNode) -> Maybe (ForeignPtr RedlandNode) -> Maybe (ForeignPtr RedlandNode) -> Initializer RedlandStatement
- statementGet :: (Ptr RedlandStatement -> IO (Ptr RedlandNode)) -> ForeignPtr RedlandStatement -> IO (Maybe (ForeignPtr RedlandNode))
- statementSet :: (Ptr RedlandStatement -> Ptr RedlandNode -> IO ()) -> ForeignPtr RedlandStatement -> Maybe (ForeignPtr RedlandNode) -> IO ()
- statementGetSubject :: ForeignPtr RedlandStatement -> IO (Maybe (ForeignPtr RedlandNode))
- statementSetSubject :: ForeignPtr RedlandStatement -> Maybe (ForeignPtr RedlandNode) -> IO ()
- statementGetPredicate :: ForeignPtr RedlandStatement -> IO (Maybe (ForeignPtr RedlandNode))
- statementSetPredicate :: ForeignPtr RedlandStatement -> Maybe (ForeignPtr RedlandNode) -> IO ()
- statementGetObject :: ForeignPtr RedlandStatement -> IO (Maybe (ForeignPtr RedlandNode))
- statementSetObject :: ForeignPtr RedlandStatement -> Maybe (ForeignPtr RedlandNode) -> IO ()
- redlandStorage :: ForeignPtr RedlandWorld -> String -> String -> String -> Initializer RedlandStorage
- redlandStorageWithOptions :: ForeignPtr RedlandWorld -> String -> String -> ForeignPtr RedlandHash -> Initializer RedlandStorage
- streamEnd :: ForeignPtr RedlandStream -> IO Bool
- streamNext :: ForeignPtr RedlandStream -> IO Bool
- streamGetObject :: ForeignPtr RedlandStream -> Initializer RedlandStatement
- redlandURI :: ForeignPtr RedlandWorld -> String -> Initializer RedlandURI
- uriFromURI :: ForeignPtr RedlandURI -> Initializer RedlandURI
- uriAsString :: ForeignPtr RedlandURI -> IO String
Exceptions
data RedlandException Source #
InitializationException | Happens when an initializer returns NULL.
Gets thrown by |
OperationException Int | Happens on non-zero return value where a
zero is expected. Gets thrown by |
StringOperationException | Gets thrown by |
ParseFailure |
FFI utility functions
type Initializer a = IO (ForeignPtr a) Source #
initialize :: IO (Ptr a) -> FinalizerPtr a -> Initializer a Source #
Initializes a Redland object, throws InitializationException
on
failure (i.e., if NULL is returned).
perform :: IO CInt -> IO () Source #
Performs an operation, throws OperationException
on failure
(i.e., on non-zero return value).
withNew :: Initializer a -> (ForeignPtr a -> IO b) -> IO b Source #
Initializes a Redland object, performs an action over it, makes
sure to call finalizeForeignPtr
afterwards.
withNullablePtr :: (a -> (Ptr b -> c) -> c) -> Maybe a -> (Ptr b -> c) -> c Source #
An abstraction to use with withCString
and withForeignPtr
.
justCString :: CString -> IO String Source #
Like maybeCString
, but requires a string to be there, and
throws StringOperationException
if it isn't.
justSharedCString :: CString -> IO String Source #
Like justCString
, but doesn't free
the C string.
World
Hashes
:: ForeignPtr RedlandWorld | world |
-> String | hash factory name (e.g., "memory") |
-> Initializer RedlandHash |
:: ForeignPtr RedlandHash | hash |
-> String | key |
-> String | value |
-> IO () |
:: ForeignPtr RedlandHash | hash |
-> String | key |
-> IO (Maybe String) |
:: ForeignPtr RedlandHash | hash |
-> String | key |
-> IO (Maybe String) |
RDF Graph (librdf_model)
:: ForeignPtr RedlandWorld | world |
-> ForeignPtr RedlandStorage | storage |
-> String | options |
-> Initializer RedlandModel | model |
modelQueryExecute :: ForeignPtr RedlandModel -> ForeignPtr RedlandQuery -> Initializer RedlandQueryResults Source #
Acts as a RedlandQueryResults
initializer.
modelFindStatements :: ForeignPtr RedlandModel -> ForeignPtr RedlandStatement -> Initializer RedlandStream Source #
Acts as a RedlandStream
initializer.
modelSync :: ForeignPtr RedlandModel -> IO () Source #
:: ForeignPtr RedlandModel | |
-> ForeignPtr RedlandURI | source URI |
-> Maybe String | parser name |
-> Maybe String | MIME type |
-> Maybe (ForeignPtr RedlandURI) | type URI |
-> IO () |
RDF term (librdf_node)
nodeFromBlankIdentifier :: ForeignPtr RedlandWorld -> Maybe String -> Initializer RedlandNode Source #
nodeFromLiteral :: ForeignPtr RedlandWorld -> String -> Maybe String -> Bool -> Initializer RedlandNode Source #
nodeFromTypedLiteral :: ForeignPtr RedlandWorld -> String -> Maybe String -> Maybe (ForeignPtr RedlandURI) -> Initializer RedlandNode Source #
nodeGetLiteralValueDatatypeURI :: ForeignPtr RedlandNode -> IO (Maybe (ForeignPtr RedlandURI)) Source #
nodeIsBlank :: ForeignPtr RedlandNode -> IO Bool Source #
nodeIsLiteral :: ForeignPtr RedlandNode -> IO Bool Source #
nodeIsResource :: ForeignPtr RedlandNode -> IO Bool Source #
nodeToString :: ForeignPtr RedlandNode -> IO String Source #
Parsers
:: ForeignPtr RedlandWorld | world |
-> Maybe String | parser name (e.g., "rdfxml", "turtle") |
-> Maybe String | MIME type |
-> Maybe (ForeignPtr RedlandURI) | type URI |
-> Initializer RedlandParser |
:: ForeignPtr RedlandParser | parser |
-> String | string to parse |
-> ForeignPtr RedlandURI | base URI |
-> ForeignPtr RedlandModel | model |
-> IO () |
Querying
:: ForeignPtr RedlandWorld | |
-> String | language name |
-> Maybe (ForeignPtr RedlandURI) | language URI |
-> String | query string |
-> Maybe (ForeignPtr RedlandURI) | base URI |
-> Initializer RedlandQuery |
Query results
:: ForeignPtr RedlandQueryResults | |
-> IO Bool |
|
queryResultsGetBindingValue :: ForeignPtr RedlandQueryResults -> Int -> Initializer RedlandNode Source #
Acts as a RedlandNode
initializer.
queryResultsGetBindingValueByName :: ForeignPtr RedlandQueryResults -> String -> Initializer RedlandNode Source #
Acts as a RedlandNode
initializer.
queryExecute :: ForeignPtr RedlandQuery -> ForeignPtr RedlandModel -> Initializer RedlandQueryResults Source #
Acts as a RedlandQueryResults
initializer.
RDF Triple (librdf_statement)
:: ForeignPtr RedlandWorld | |
-> Maybe (ForeignPtr RedlandNode) | subject |
-> Maybe (ForeignPtr RedlandNode) | predicate |
-> Maybe (ForeignPtr RedlandNode) | object |
-> Initializer RedlandStatement |
statementGet :: (Ptr RedlandStatement -> IO (Ptr RedlandNode)) -> ForeignPtr RedlandStatement -> IO (Maybe (ForeignPtr RedlandNode)) Source #
An abstraction used for getting statement components.
statementSet :: (Ptr RedlandStatement -> Ptr RedlandNode -> IO ()) -> ForeignPtr RedlandStatement -> Maybe (ForeignPtr RedlandNode) -> IO () Source #
An abstraction used for setting statement components.
statementSetSubject :: ForeignPtr RedlandStatement -> Maybe (ForeignPtr RedlandNode) -> IO () Source #
statementGetPredicate :: ForeignPtr RedlandStatement -> IO (Maybe (ForeignPtr RedlandNode)) Source #
statementSetPredicate :: ForeignPtr RedlandStatement -> Maybe (ForeignPtr RedlandNode) -> IO () Source #
statementSetObject :: ForeignPtr RedlandStatement -> Maybe (ForeignPtr RedlandNode) -> IO () Source #
Triple stores
:: ForeignPtr RedlandWorld | world |
-> String | storage type name ("hashes", "memory", "file", etc) |
-> String | storage identifier |
-> String | options |
-> Initializer RedlandStorage |
redlandStorageWithOptions Source #
:: ForeignPtr RedlandWorld | world |
-> String | storage type name ("hashes", "memory", "file", etc) |
-> String | storage identifier |
-> ForeignPtr RedlandHash | options |
-> Initializer RedlandStorage |
Stream of triples (librdf_statement)
streamEnd :: ForeignPtr RedlandStream -> IO Bool Source #
:: ForeignPtr RedlandStream | |
-> IO Bool |
|
URI
:: ForeignPtr RedlandWorld | world |
-> String | URI string |
-> Initializer RedlandURI |
uriAsString :: ForeignPtr RedlandURI -> IO String Source #