Generic traits of various algebraic structures for Scala