brendanzab / algebra

Abstract algebra for Rust (still very much a WIP!)
Apache License 2.0
60 stars 9 forks source link

Extracting operators to ZSTs and other refactorings #28

Closed WaDelma closed 8 years ago

WaDelma commented 8 years ago

This resolves #18.

This extracts operators from structural traits so both Additive and Multiplicative traits use the same one trait:

trait MagmaAdditive {}
trait MagmaMultiplacative {}

->

struct Additive;
struct Multiplicative;
trait Magma<O: Op> {}

This also includes improvements that I found out for assisting inference.

There is also a wrapper type that allows using operators with algebraic stuff.

This commit also includes tons of refactoring... For one I removed the old_stuff folder, because this project is using version control and keeping old stuff in a folder seems silly.

I also included example code that demonstrates the usage of the library.

sebcrozet commented 8 years ago

The use of ZST is interesting. I believe your concept of "wrapper struct" might be given a mathematical fundation. If I understand correctly, this basically maps an element from a set to the same element of the same set endowed with some extra structure, i.e. an identity map Id: S -> (S, ★) where is the operator needed to make it a Magma. I don't remember the actual name of this kind of identity though.

By the way, thanks for your steady work on this project. It's been a long time since I looked seriously at it and I might consider attempting to actually use it!

brendanzab commented 8 years ago

Nice stuff! Thanks!