Created
August 24, 2020 15:44
-
-
Save bblfish/2309886707c9a0b28b01162ee817f672 to your computer and use it in GitHub Desktop.
Trying to get the types in dotty to line up.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.w3.banana | |
import org.w3.banana._ | |
trait RDFOps[Rdf <: RDF & Singleton](using val Rdf: RDF) { | |
def emptyGraph: Rdf.Graph | |
} | |
trait PointedGraph[Rdf <: RDF & Singleton](using val ops: RDFOps[Rdf]) { | |
def pointer: ops.Rdf.Node | |
def graph: ops.Rdf.Graph | |
} | |
object PointedGraph { | |
def apply[Rdf <: RDF & Singleton](using ops: RDFOps[Rdf])( | |
node: ops.Rdf.Node, | |
inGraph: ops.Rdf.Graph | |
): PointedGraph[ops.Rdf.type] = | |
new PointedGraph[ops.Rdf.type](){ | |
val pointer = node | |
val graph = inGraph | |
} | |
def apply[Rdf <: RDF & Singleton](using ops: RDFOps[Rdf])(node: ops.Rdf.Node): PointedGraph[ops.Rdf.type] = | |
this.apply[ops.Rdf.type]()(node, ops.emptyGraph) | |
def unapply[Rdf <: RDF & Singleton](using ops: RDFOps[Rdf])( | |
pg: PointedGraph[ops.Rdf.type] | |
): (pg.ops.Rdf.Node, pg.ops.Rdf.Graph) = (pg.pointer, pg.graph) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok this compiles: