Git Product home page Git Product logo

Comments (12)

robstewart57 avatar robstewart57 commented on July 20, 2024 1

Hi @tonicebrian Thanks for the proposal.

I could do the same for all other standard vocabularies but if you think it doesn't belong here, I can create a library just with the vocabularies in it and just depend on rdf4h

Take a look at @fabianmeyer 's rdf4h-vocabulary-generator and rdf4h-vocabulary packages. The approach uses template Haskell to read a schema from a Turtle file, and generates a Haskell module at compile time e.g.

$(genVocabulary "resources/shacl.ttl")

The two advantages I see are:

  1. You don't have to implement the Haskell modules by hand for each vocabulary.
  2. You avoid mistakes e.g. typo mistakes in URIs, property strings, etc.

Two possible disadvantages are:

  1. You are committed to the choices made by the implementation of genVocabulary, which might not meet your needs.
  2. If you wanted to use this template Haskell technique for your own schemas, then you only get the module at compile time, limiting the ability to inspect it during development and IDE features e.g.

it would be super handy if common terms for SKOS were part of the library so I could use autocomplete

in which case you'd need to compile your SKOS vocab module with genVocabulary first, then develop another module that uses SKOS.hs.

@tonicebrian does rdf4h-vocabulary-generator meet your needs?

from rdf4h.

robstewart57 avatar robstewart57 commented on July 20, 2024

Hi @tonicebrian good idea, and this has been something I've been meaning to add to this library. For SKOS, and other commonly used vocabularies.

I will reply to you here when I've added this functionality.

from rdf4h.

tonicebrian avatar tonicebrian commented on July 20, 2024

Hi Rob, I'm willing to contribute this myself. If you have some ideas about structure, just put here a minimal template/structure and I will follow it. Otherwise I could do a "proposal" for SKOS and discuss that in the PR.

I'm planning to use rdf4h in a project and the missing things in the library are short term the vocabularies and long term the ability to work with Namedgraphs, so I'd prefer that you spend your time working on harder issues 😄

from rdf4h.

tonicebrian avatar tonicebrian commented on July 20, 2024

Hey, @robstewart57 did you like the structure I picked for the Vocabularies in #108 . I could do the same for all other standard vocabularies but if you think it doesn't belong here, I can create a library just with the vocabularies in it and just depend on rdf4h

from rdf4h.

tonicebrian avatar tonicebrian commented on July 20, 2024

Hi @robstewart57 yes, I on paper it solves completely what I was looking for. But I tried to compile it and I get compilation errors so maybe it is abandoned.

rdf4h-vocabulary          > /home/cebrian/GIT/rdf4h-vocabulary/src/Data/RDF/Vocabulary/XSD.hs:1:1: error:
rdf4h-vocabulary          >     Exception when trying to run compile-time code:
rdf4h-vocabulary          >       ParseFailure "Parse failure: \n(line 7, column 2):\nunexpected Cannot resolve IRI: Scheme head: not enough input (Nothing,Nothing,\"\")\nexpecting subject resource"
rdf4h-vocabulary          > CallStack (from HasCallStack):
rdf4h-vocabulary          >   error, called at src/Data/RDF/Vocabulary/Generator/VocabularyGenerator.hs:24:23 in rdf4h-vocabulary-generator-0.1.0.0-2J3xItsPFIeIMGirmv8qwN:Data.RDF.Vocabulary.Generator.VocabularyGenerator
rdf4h-vocabulary          >     Code: genVocabulary "resources/xsd.ttl"

I'll have a closer look if I have time, but for this ticket I think you can close it. Either it requires a fix to that repo or to create a tool along these lines.

from rdf4h.

koslambrou avatar koslambrou commented on July 20, 2024

@robstewart57 Do you think those packages should be integrated into rdf4h or kept in a separate repository ?

from rdf4h.

robstewart57 avatar robstewart57 commented on July 20, 2024

@tonicebrian in your clone of rdf4h-vocabulary, change resources/xsd.ttl.

Change line 7 from:

<> rdfs:label "XSD Namespace Document";

to:

xsd: rdfs:label "XSD Namespace Document";

Then try compiling.

from rdf4h.

robstewart57 avatar robstewart57 commented on July 20, 2024

@koslambrou

Do you think those packages should be integrated into rdf4h or kept in a separate repository ?

I've thought about that too. The author of the packages, @fabianmeyer , has previously indicated this would be fine.

The main issue I see is the added template-haskell dependency rdf4h-vocabulary-generator would bring into rdf4h. But since stackage now stores pre-compiled packages, this is perhaps a lower cost to compile times it would have been in the past. It also depends on classy-prelude, but I assume that could be removed if these two libraries are absorbed into the rdf4h library.

Compiling the actual RDFS.hs, XSD.hs, SHACL.hs etc modules takes ~10 seconds, so not a huge cost.

from rdf4h.

tonicebrian avatar tonicebrian commented on July 20, 2024

Hi @robstewart57 that solved the problem.

@koslambrou and @robstewart57 if you accept a suggestion, I think it would be a super good addition to rdf4h. First because coming myself from rdf4j I was expecting something similar here (or at least a clear sign pointing to those libraries). And if you are going to include them in the library, please unroll symbols from template haskell into regular Haskell source code files. When I was looking for a functionality like this one I was looking for autocomplete and to avoid silly typos when coding applications.

If I'm not able to check symbols we are again as blind as before when we could type the whole IRI in text.

from rdf4h.

robstewart57 avatar robstewart57 commented on July 20, 2024

@tonicebrian @koslambrou This has been implemented in the schema-vocab branch with this commit: b3463e7

@tonicebrian when you build the rdf4h library now (on the schema-vocab branch), it will create and compile some additional modules:

  • Data.RDF.Vocabulary.DCTerms
  • Data.RDF.Vocabulary.OWL
  • Data.RDF.Vocabulary.RDF
  • Data.RDF.Vocabulary.RDFS
  • Data.RDF.Vocabulary.SHACL
  • Data.RDF.Vocabulary.VANN
  • Data.RDF.Vocabulary.XSD

Your IDE's auto-complete support should be able to find these modules. If you run the haddock tool you should also be able to generate HTML documentation for these Haskell modules that are generated at compile time. E.g. if using stack, then stack haddock, which prints the filepath to the index.html HTML file for rdf4h.

Adding more common schemas to rdf4h should just be a case of adding a Turtle schema file in the resources/ directory and creating a stub Haskell module in Data.RDF.Vocabulary. Or you can also use the genVocabulary Template Haskell function in your own application code.

Does this work for you?

from rdf4h.

tonicebrian avatar tonicebrian commented on July 20, 2024

Hey @robstewart57 yes, this works for me. If you could please add FOAF and SKOS to this first PR it would be super nice.

from rdf4h.

robstewart57 avatar robstewart57 commented on July 20, 2024

@tonicebrian done #110 .

from rdf4h.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.