Important traits which don't need HKTs
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
While we're waiting for HKTs, there are a lot of useful traits which don't need them, and which we should think about adding, especially if we do have associated types.
The most obvious ones are Semigroup and Monoid. There is an existing proposal concerning a semigroup trait, under the name Combine (full disclosure: which I suggested), albeit also tied to a new operator overload.
Other prior art from Haskell:
Many (theoretically well-founded) monomorphic type classes for things which are "like lists" or "like strings" exist in the monoid-subclasses package. (See also the GitHub page, which has more information and important links.)
The mono-traversable package has monomorphic versions of the Functor/Foldable/Traversable hierarchy, which is valuable in that they can also be used with monomorphic containers (think String, Bitv), so there is demand for these even though Haskell does also have HKTs. There are also some classes (marked experimental) which are seemingly similar to the ones from monoid-subclasses, but using associated types.
The point is that we will probably want traits like these even if we do grow HKTs, so there's no real reason to wait (apart from having more important things on our plate).
For the most part we should be able to just copy many of these ideas, but there are some things we need to, or should want to, put extra thought into:
- Issues related to ownership (move semantics, borrowing). Haskell doesn't have to worry about where to take things by reference and where by value; we do.
- Mutability. While we probably do want the same methods as the Haskell classes for non-destructive manipulation, we probably also want ones which do in-place updates in addition to them.
- Naming. We might want to lean in the direction of more approachable, "intuition-capturing", rather than more precise, mathematical names (
Functor->Map/Mappable,Semigroup->Combine, and so on), but coming up with these, especially for everything, is hard. We also have to think about how to distinguish monomorphic versions from future HKT-using ones. (Themono-traversablepackage usesMonoandoprefixes, of which, in my opinion, the former is not bad, and the latter is quite awful.)
(List is not necessarily exhaustive.)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the issue body and the linked Combine proposal in RFC pull request 203, then review the referenced Haskell monoid-subclasses and mono-traversable packages. A useful outcome would require a settled proposal for which traits to add, their ownership and mutability behavior, and naming; no implementation files or tests are identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100