This is a small part of a project called Architector, which suppose to help Dotty programmers to get rid of a big piece of boilerplate.
The library containts traits describing algebraic structures in a categorial theoretic sense. Such as:
- Category
- Semicategory
- Semigroup
- Monoid
- Groupoid
- Group
- Ring
and others.
It was decided to refuse usual practice of typeclass inheritance because of knows issues.
All properties were moved to usual traits in algebra/stones and bricks folders. They inherite from each other in a usual way. The structure is described in a diagram below.
It is easy to extend usual traits for creating custom typeclasses.
Many examples are in the instance folder and tests.
Create an instance:
implicit def intRing: Ring[Int] = new Ring[Int] {
override def zero: Int = 0
override def add(a: Int, b: Int): Int = a + b
override def one: Int = 1
override def mult(a: Int, b: Int): Int = a * b
override def negation(a: Int): Int = -a
}