- From: Jean-Marc Vanel <jeanmarc.vanel@gmail.com>
- Date: Mon, 13 Jul 2015 17:11:52 +0200
- To: "public-banana-rdf@w3.org" <public-banana-rdf@w3.org>
- Message-ID: <CANwvFKD_cbMcPKUjmhg6zWp2=cVnH-UpL0RQQs3u58Ympg86Zg@mail.gmail.com>
Hi all All of the Banana tests use classes , not traits. However, the best practice for modularizing with Scala seems to use traits. The Banana documentation is geared towards people extending the framework e.g. for adding support to new RDF engines. But there is not really a documentation oriented toward appplication developers. And the only open source Banana applications are mine, so there is no other source of inspiration. Does this mean that Banana is only for the beauty of the code ? I don't think so ! This being said, here is a short trait that is not compiling. In the last mounths, I tried several designs, but I was not able to find some design patterns for Banana with traits. The compile message is: type mismatch; found : query.type (with underlying type TestTrait.this.Rdf#ConstructQuery) required: Rdf#ConstructQuery And the code : package deductions.runtime.services import scala.util.Try import org.w3.banana.RDF import org.w3.banana.RDFOps import org.w3.banana.RDFStore import org.w3.banana.SparqlEngine import org.w3.banana.SparqlOps import org.w3.banana.syntax._ import org.w3.banana.SparqlOpsModule trait RDFStoreLocalProvider[Rdf <: RDF, DATASET] { implicit val rdfStore: RDFStore[Rdf, Try, DATASET] val dataset: DATASET } trait TestTrait[Rdf <: RDF, DATASET] extends RDFStoreLocalProvider[Rdf, DATASET] with SparqlOpsModule { implicit val ops: RDFOps[Rdf] val queryString = s""" |CONSTRUCT { ?thing ?p ?o } WHERE { | graph ?g { | ?thing ?p ?o . | FILTER regex( ?o, "search", 'i') | } |}""".stripMargin import ops._ import sparqlOps._ import rdfStore.sparqlEngineSyntax._ def lookup(search: String) = { val graph = for { query <- parseConstruct(queryString) es <- dataset.executeConstruct(query, Map()) // ERROR } yield es val triples = ops.getTriples(graph) // ERROR } } -- Jean-Marc Vanel Déductions SARL - Consulting, services, training, Rule-based programming, Semantic Web http://deductions-software.com/ +33 (0)6 89 16 29 52 Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui
Received on Monday, 13 July 2015 15:12:24 UTC