Do you know any language where you create generic collection and just specify what you require of it?
For example, you might specify that you require collection to be indexed with numbers, and have quick access to elements by their index. Or have ability to add element at the end quickly or have the ability to find next element quickly. Or have elements with quick parent access, or quick children access, or quick arbitrary inserts or you want collection to be indexed multidimensionally.
Language itself would pick the right algorithms for your collection for example picking fixed length immutable array (for the purposes of iteration), but also set (for quickly checking presence of element).
Creation, access and writing should be kept as similar as possible with different algorithms.
This system should of course be extensible. So that you could implement fast access to elements by creating and updating various task specific indexes into your data and have them available though built in language syntax.
The only thing that comes to my mind that somewhat attempted this is C++ template library, which offers various collections and iterators while trying to keep the interface mostly algorithm agnostic.
"Clojure uses the ISeq interface to allow many data structures to provide access to their elements as sequences.
The seq function yields an implementation of ISeq appropriate to the collection.
Seqs differ from iterators in that they are persistent and immutable, not stateful cursors into a collection.
As such, they are useful for much more than foreach - functions can consume and produce seqs, they are thread safe, they can share structure etc."
Seqs do not handle the "here is my requirement, pick a collection for me" feature you want, but rather "here is a collection, run this algorithm"
You could definitely do it with C++ template metaprogramming and type traits.
> For example, you might specify that you require collection to be indexed with numbers...
You can't hide that, because in at least some of the uses of that collection, you're going to index it by numbers.
Other than that kind of detail, though, I think you can create collections that you can use without knowing the details in Haskell. To a lesser degree, you can in C++.
The last detail is creation. You might be able to create a "collection factory" to create it for you. But I'm not sure that it's any different to say "CollectionFactory.createCollection(FAST_FIND)" than it is to say "new HashMap()". I mean, the former means that you don't have to know that a HashMap is the collection you're looking for, so that's something. It's not all that much, though.
But you can do that with every library by yourself.