# Introduce a \`MaterializableCollection\` protocol

**URL:** <https://forums.swift.org/t/introduce-a-materializablecollection-protocol/12492>\
**Category:** Pitches\
**Created:** [May 8, 2018, 9:03pm UTC](https://forums.swift.org/t/introduce-a-materializablecollection-protocol/12492 "2018-05-08T21:03:54Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![jawbroken](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jawbroken](https://forums.swift.org/u/jawbroken)\
**Post date:** [May 9, 2018, 11:37pm UTC](https://forums.swift.org/t/introduce-a-materializablecollection-protocol/12492/12 "2018-05-09T23:37:20Z")

</div>

Sorry, the `prefix(while:)` thing was a rhetorical question, explaining why I think this is more a documentation thing than actually encoding the complexity in the type system. For many parts of the API, the type system can't help you determine if the resulting `Collection` is materializable or not (I did a [brief non-exhaustive survey](https://forums.swift.org/t/pitch-make-collection-super-convenient-and-retire-sequence/12103/32) in one of the other `Sequence`/`Collection` threads).

I remain unconvinced about `MaterializableCollection`, versus `RandomAccessCollection` because of the exact difference you mention. The type system can't help much and the harm of an infinite loop seems benign, because the error is generally obvious and “local”. I don't see your question strictly as a generalisation of mine, because in cases where the type system can easily help (e.g. `RandomAccessCollection`) and/or the error is particularly harmful or hard to diagnose, then the tradeoff is different.

---

_[View the full topic](https://forums.swift.org/t/introduce-a-materializablecollection-protocol/12492)._
