- From: Jean-Marc Vanel <jeanmarc.vanel@gmail.com>
- Date: Sun, 16 Aug 2015 09:24:00 +0200
- To: "public-banana-rdf@w3.org" <public-banana-rdf@w3.org>
- Message-ID: <CANwvFKAnsM7V33S84i1Hcvn4kFfKoB0M1nv5p=d_E94XDEauDw@mail.gmail.com>
Hi
A fixed code for the original problem is here:
https://github.com/jmvanel/semantic_forms/blob/master/scala/forms/src/test/scala/deductions/runtime/services/TestTrait.scala
And I cannot do better than paste Anton's response on Gitter Banana chat:
The problem here is that @jmvanel extends SparqlOpsModule and
SparqlOpsModule extends RdfModule:
trait RDFModule {
type Rdf <: RDF
}
As you see this module forces you to define Rdf type alias. While @jmvanel
has generic parameter with the same name:
trait TestTrait[Rdf <: RDF, DATASET]
and that breaks his code, because type alias and generic type parameter are
two different entities.
[..]
My conclusion is that if you want to just use Banana-RDF in your
application, and you use Rdf generic type parameter, you should not extend
Modules because of this problem, and you should resolve ops from type
parameter instead.
2015-07-13 17:11 GMT+02:00 Jean-Marc Vanel <jeanmarc.vanel@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
>
--
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 Sunday, 16 August 2015 07:24:29 UTC