fantasyland / fantasy-land

Specification for interoperability of common algebraic structures in JavaScript
MIT License
10.12k stars 374 forks source link

Any interest in adding a `Group` spec? #269

Closed evilsoft closed 6 years ago

evilsoft commented 7 years ago

Groups for all?

image

While it is really strict and probably not grabbed for a lot, I was wondering if it would be beneficial to add a Group spec with the following bits and bobs:

Group

A value that implements the Group specification must also implement the Monoid specification.

  1. g.concat(g.inverse()) is equivalent to g.empty() (right inverse)
  2. g.inverse().concat(g) is equivalent to g.empty() (left inverse)

inverse method

inverse :: Group g => g ~> () -> g
evilsoft commented 7 years ago

Actually. Maybe because it is on an instance, it should be more VERB-y and go with invert like Haskell.

evilsoft commented 7 years ago

Well one person is good enough for me!! Submitted this PR to address this issue.