Thanks @kai for the idea of using pattern matching on types and the TypeTest idea.
TypeTests do allow me to now pattern match on types as shown here
bKt.asMatchable match
case Triple(sub: URI,rel,obj: URI) => ...
For simple types such as URIs it could be well argued that this is all that is needed.
For more complex types such as RDF literals, which are elements of the disjunctive type String + String⨉Lang + String⨉URI
we may want to pattern match inside the pattern. But if I try to change the type test here to this
t.asMatchable match
case Triple(Bbl,Name,Literal(lit)) => ...
I get the error message
case Triple(Bbl,Name,Literal(lit)) =>
^^^^^^^^^^^^
pattern selector should be an instance of Matchable, but it has unmatchable type rdf.Node instead
Ideally I would want to go one step further with something functionally equivalent to this, but more elegant:
t.asMatchable match
case Triple(Bbl,Name,Literal(LangLit("Henry",en))) => ...
but that does not compile either.