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 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.