Blog post series: Alternative type constructors and HKT

It is not necessary. I wanted to separate out the idea of a "family of collections" as a distinct concept, since it maps well to HKT, but maybe it would have been simpler to start with an Other<U> sort of thing.

Interestingly, I suspect we would want neither of these in practice -- at least not for collections. This is because collections often place bounds on their members (e.g., that they must be hashable). So something like you proposed:

trait Collection<T> {
    // ...
    type SelfCollection<S>: Collection<S>;
}

couldn't be implemented by HashSet<K>, because it would need type SelfCollection<S: Hash>. The same is true for collection families. I will get into this a bit more in the upcoming posts..

1 Like