From 8d3da9e7af2ae5986d3551cea8dee39ea9b2cdd6 Mon Sep 17 00:00:00 2001 From: defanor Date: Thu, 22 Feb 2018 13:19:18 +0300 Subject: Refine the documentation --- Redland.hs | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) (limited to 'Redland.hs') diff --git a/Redland.hs b/Redland.hs index 397da47..4bfa88d 100644 --- a/Redland.hs +++ b/Redland.hs @@ -1,4 +1,88 @@ -module Redland where +{- | +Module : Redland +Maintainer : defanor +Stability : unstable +Portability : non-portable (GHC extensions are used) + bindings. See + for in-depth +descriptions. + += Library organization + +- Raw bindings are provided by "Redland.LowLevel". Normally they + should not be used directly. + +- Refined versions (using Haskell types) of those are provided by + "Redland.MidLevel". One should still be careful with the allocated + resources while using those, for instance by using 'withNew'. A rule + of thumb is that whenever you see an 'Initializer', it's a good idea + to wrap it into 'withNew'. + +- Utility functions and types are provided by "Redland.Util". Those + don't strictly correspond to functions of the original API. + + += Usage example + +> import Redland +> +> input :: String +> input = "\ +> \ \ xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\ +> \ \ +> \ Dave Beckett's Home Page\ +> \ Dave Beckett\ +> \ The generic home page of Dave Beckett.\ +> \ \ +> \\ +> \" +> +> main :: IO () +> main = +> withWSMU "memory" [] "example" "" "http://example.librdf.org/" $ +> \world storage model uri -> do +> -- parse and insert +> guessingParseStringIntoModel world model uri input +> -- query +> withQuery world model "sparql" +> "SELECT ?foo ?bar ?baz WHERE { ?foo ?bar ?baz }" (Just uri) $ +> mapM_ print +> -- search statements +> withStatements world model (Triple Nothing Nothing Nothing) $ +> mapM_ print + +It prints the following: + +> [("foo",ResourceNode "http://www.dajobe.org/"),("bar",ResourceNode "http://purl.org/dc/elements/1.1/title"),("baz",LiteralNode "Dave Beckett's Home Page")] +> [("foo",ResourceNode "http://www.dajobe.org/"),("bar",ResourceNode "http://purl.org/dc/elements/1.1/creator"),("baz",LiteralNode "Dave Beckett")] +> [("foo",ResourceNode "http://www.dajobe.org/"),("bar",ResourceNode "http://purl.org/dc/elements/1.1/description"),("baz",LiteralNode "The generic home page of Dave Beckett.")] +> Triple {subject = Just (ResourceNode "http://www.dajobe.org/"), predicate = Just (ResourceNode "http://purl.org/dc/elements/1.1/title"), object = Just (LiteralNode "Dave Beckett's Home Page")} +> Triple {subject = Just (ResourceNode "http://www.dajobe.org/"), predicate = Just (ResourceNode "http://purl.org/dc/elements/1.1/creator"), object = Just (LiteralNode "Dave Beckett")} +> Triple {subject = Just (ResourceNode "http://www.dajobe.org/"), predicate = Just (ResourceNode "http://purl.org/dc/elements/1.1/description"), object = Just (LiteralNode "The generic home page of Dave Beckett.")} + + +-} + +module Redland ( module Redland.MidLevel + , module Redland.Util + , RedlandWorld + , RedlandHash + , RedlandModel + , RedlandNode + , RedlandParser + , RedlandQuery + , RedlandQueryResults + , RedlandStatement + , RedlandStorage + , RedlandStream + , RedlandURI + , ForeignPtr + ) +where + +import Foreign +import Redland.LowLevel import Redland.MidLevel import Redland.Util -- cgit v1.2.3