Q:

Contravariant binary operations in Scala

For a very basic generic model of categories, I'm trying to get the morphism associated with a pair of objects in a contravariant fashion.
class Obj[DerivedObj <: Obj[DerivedObj]] { /* ... */ }

class Morphism[DerivedMorphism <: Morphism[DerivedMorphism]] { /* ... */ }

I'd like to somehow be able to define:
def mor( from : SomeConcreteObj, to : SomeConcreteObj ) : SomeConcreteMorphism;

but the `obvious' solution of making mor a method of Obj would require Obj to be additionally type-parameterized by Morphism.
What's the Scala way of achieving such a thing?

A:

OK, bad entity relationship on my part. Presumably the implication is that mor is actually a method of some Category class:
trait Cat[O,M] {
   def mor( from : O, to : O ) : M;

}

which would seem to solve the problem.

