I am trying to make my Graph to implement Traversable for it's edges. I have a type of edge called Edge[Node, EdgeType]. My edge is a final case class. The code looks like this:
class Graph[Node, Type] extends Traverasble[Edge[Node, Type]]
I saw this post about creating a custom Traversable, but I can't make it work. My Graph knows it's element, Edge, but not its parameter type, Node and EdgeType. I couldn't make the Factory to understand those generics.
object Graph extends TraversableFactory[Graph] {
implicit def canBuildFrom[A<:Edge[_,_]]: CanBuildFrom[Coll, A, Graph[_]] = new GenericCanBuildFrom[A]
def newBuilder[A<:Edge[_,_]] = new ListBuffer[A] mapResult (x => new Graph(x:_*))
}
I tried to use higherKinds, but I don't see how solve it with same either.
Do you know how I can solve this? This problem returns everytime a class with some generics extends Traversable that it's Elem is a composition of the class generics.