amccausl / RDF4H

rdf4h is a library for working with RDF in Haskell
http://protempore.net/rdf4h/
Other
8 stars 2 forks source link

needed a fix in cabal file for GHC 7.0.3 (plattform 2011.2.0.1) #1

Open stgit opened 13 years ago

stgit commented 13 years ago

Hi

RDF4H is really great!!! People use it ;-)

Could you possibly provide an example? Like a few lines where you read a turtle rdf file and make a simple query on it? I am trying to figure it out myself but it takes some hours for me. (also since I am not ye fully familiar with haskell...)

For ghc 7.0.3 I needed to fix the ".cabal" file to get it working. I did the following changes (just guessed what might work, so not sure):

Her is the diff for "rdf4h.cabal":

55a56
>                  , test-framework-quickcheck2 >= 0.2.9
101,102c102,103
<                  , QuickCheck >= 1.2.0.0 && < 1.3
<                  , HUnit >= 1.2.2.1 && < 1.3

---
>                  , QuickCheck >= 1.2.0.0 && < 1.5
>                  , HUnit >= 2.4.1.1 && < 3
amccausl commented 13 years ago

Hey. It's good to know someone is interested :). I should have some time to generate a proper readme over the weekend (likely tomorrow). I hope that's early enough for your purposes.

stgit commented 13 years ago

Hey. Looking forward to the README file. Is the most resent version of the code actually on github or in the darcs repository? I managed to hack some code together to open a turtle rdf file and to run a query. Is really hacked code, as you can see:

instance Show TriplesGraph where show gr = concatMap (\t -> show t ++ "\n") (queryClasses gr)

rdffile :: String
rdffile = "/home/steve/Develop/myhaskell/myrdf/bookmarks.ttl"

main :: IO ()
main = do loadInputGraph rdffile >>= putStrLn . show

query'' :: TriplesGraph -> Maybe Subject -> Maybe Predicate -> Maybe Object -> Triples
query'' gr s p o = removeDupes $ filter (matchPattern s p o) (triplesOf gr)

queryClasses :: TriplesGraph -> Triples 
queryClasses gr = query'' gr Nothing Nothing (Just (unode (s2b "http://www.w3.org/2002/07/owl#Class")) )

loadInputGraph :: String -> IO (Either ParseFailure TriplesGraph)
loadInputGraph name =
  B.readFile (name) >>=
    return . parseString (TurtleParser mtestBaseUri (mkDocUrl testBaseUri name)) >>= return . handleLoad

What would be the right way to run a query from main::IO?

From what I seen so far the source code of RDF4H is VERY readable and nice!!