Skip to content

Commit

Permalink
smallest change to make PROBLEM reappear
Browse files Browse the repository at this point in the history
  • Loading branch information
bblfish committed Nov 24, 2022
1 parent 4159ccd commit eaf445a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
21 changes: 15 additions & 6 deletions scala/RDF.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,31 @@ trait RDF:
rdf =>

type R = rdf.type

type Node <: Matchable
type URI <: Node
type rNode <: Matchable
type rURI <: rNode
type Node <: rNode
type URI <: Node & rURI

given rops: ROps[R]
end RDF

object RDF:

type rNode[R <: RDF] = R match
case GetRelativeNode[n] => n & Matchable

type rURI[R <: RDF] = R match
case GetRelativeURI[u] => u & rNode[R]

type Node[R <: RDF] = R match
case GetNode[n] => n
case GetNode[n] => n & rNode[R]

type URI[R <: RDF] <: Node[R] = R match
case GetURI[u] => u & Node[R]

case GetURI[u] => u & Node[R] & rURI[R]

private type GetRelativeNode[N] = RDF { type rNode = N }
private type GetNode[N] = RDF { type Node = N }
private type GetRelativeURI[U] = RDF { type rURI = U }
private type GetURI[U] = RDF { type URI = U }

end RDF
Expand Down
8 changes: 5 additions & 3 deletions scala/RDF_Class.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ object ClassTypes {
object ClassRDF extends generic.RDF:
import class_based.ClassTypes as cz
import generic.*

override opaque type Node <: Matchable = cz.Node
override opaque type URI <: Node = cz.Uri

override opaque type rNode <: Matchable = cz.Node
override opaque type rURI <: rNode = cz.Uri
override opaque type Node <: rNode = cz.Node
override opaque type URI <: Node & rURI = cz.Uri

given rops: generic.ROps[R] with
override def mkUri(str: String): Try[RDF.URI[R]] = Try(
Expand Down
6 changes: 4 additions & 2 deletions scala/RDF_UsingScalaTrait.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import generic.*
// todo, put back example using traits only to see if Java is the problem
object TraitBasedRDF extends RDF:
lazy val factory: rdfscala.ScalaMkNodes = rdfscala.SimpleScalaNodeFactory
override opaque type Node <: Matchable = rdfscala.TstNode
override opaque type URI <: Node = rdfscala.URI
override opaque type rNode <: Matchable = rdfscala.TstNode
override opaque type rURI <: rNode = rdfscala.URI
override opaque type Node <: rNode = rdfscala.TstNode
override opaque type URI <: Node & rURI = rdfscala.URI

given rops: ROps[R] with
override def mkUri(str: String): Try[RDF.URI[R]] = Try(
Expand Down

0 comments on commit eaf445a

Please sign in to comment.