I’m not sure I fully understand your problem and whether type classes (or other implicit usages) might be a part of a solution. It might help if you provided minimal, self-contained examples that highlight the structure of the problem instead of reworked extracts from your actual code base.
- Is the implementation of
#treeAggregate()relevant to the problem? - What other containers would you want to provide
#treeAggregate()to, and how - via completely separate implementations? Are the three questions below related to this part at all? - What’s
ClauseAsList,BinaryOperation, etc.? Type aliases are nice if they can be looked up and if the corresponding types are used excessively - not in this kind of example. - Just wondering: Couldn’t
seqopandAbe left out in exchange for an upstream#map()invocation?
It’s showing how to create a type class Show (that incidentally happens to have one method only) with instances for String and Int. The ShowOps wrapper is just sugar on top and not part of the type class concept as such.
This could probably already be written as
treeAggregate(clause, ident, Bdd(_), op)
So far this doesn’t invoke the concept of type classes.
implicit class TraversableTreeAggregate[A](val objects: TraversableOnce[A]) extends AnyVal {
def treeAggregate[B](init: B, seqop: A => B, combop: (B, B) => B): B =
Aux.treeAggregate(objects, init, seqop, combop)
}
This one I don’t understand.