Summary

The definition of the abelian group concludes our discussion of abstract algebraic structures; that is, the structures solely defined by the laws they satisfy.

We looked at three such structures: semigroup, monoid, and group. The semigroup is defined by a binary operation that is closed and associative. The monoid adds to this an identity element so that the operation applied to it and another argument returns the second argument unchanged. The group extends monoids with an invertibility law, stating that for each element there should be another element so that the operation applied on them returns an identity element. If the operation defined by the group is commutative, the group is called abelian.

We provided an example implementation for all these algebraic equations, along with ScalaCheck properties for verifying that our implementations are sane.

Needless to say, our code is for demonstration purposes only, and because of this, it is quite simplistic.

There are at least two major functional programming libraries in the Scala ecosystem in which the concepts we discussed are implemented more rigorously—cats (https://typelevel.org/cats/), and scalaz (https://github.com/scalaz/scalaz). They are well-documented and regularly blogged and talked about, and provide a solid grounding for readers who are curious about using the notions we've talked about in real-life projects.

In the next chapter, we’ll work out our abstraction muscle by studying effects in general, extending the toolbox we started to fill in Chapter 6Exploring Built-In Effects, with new concepts.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.37.12