Spire defines around 80 typeclasses, including 30 coming from algebra and cats-kernel. We’ll see how much of that structure is dictated by mathematical laws, and which parts are the result of design decisions that balance different tradeoffs. In particular, we’ll discuss the different roles played by typeclasses in the Scala ecosystem:
- as encoding operations obeying well-defined laws,
- as enabling the use of a particular syntax for those operations, if possible close to the mathematical notation of a domain (and subfields often disagree on the notation!),
- defining a context in which a combination of typeclasses implicitly imposes additional laws (for example, the ordering of numbers and addition),
- enabling the user to change the variant of a relation being used (Order),
- singling out one variant of a structure as canonical (cats: the additive Group for integers),
- as selecting a particular algorithm for an operation (integer factorization: deterministic or Monte-Carlo).
It quickly becomes apparent that these roles conflict. With this in mind, we’ll have a look at some design choices made in Spire. We’ll discuss success stories, such as the clarification of the laws of the % operator, the commutative ring tower that formalizes integer factorization and Euclidean division. We’ll also discuss parts where trade offs have been made, such as the triplication of group structures (Group, AdditiveGroup, MultiplicativeGroup), the problem of coherent instances, especially when various typeclasses are combined. Time permitting, we’ll also discuss issues with law-based property checks (precision, range, time and memory complexity).
* Event *
Typelevel Summit Lausanne, June 2019: typelevel.org/...
* About Speaker *
I’m a researcher in quantum physics with a strong interest in convex optimization and numerical/symbolical computing. I’ve been using Scala&Play since I wanted to build a database of research results, and Play seemed to be a reasonable solution. I fell in love with the Scala language since then, and am contributing to its open source ecosystem (Spire + personal libraries for mathematical computations).
* Licensing *
This recording is licensed under CC-BY 4.0 (creativecommon....
Негізгі бет Lord of the rings: the Spire numerical towers - Denis Rosset
Пікірлер