I think what you are looking for are type-indexed data structures. For the most part they are fortuitously supported by the CLR if you only need one instance of the dictionary. (Sorry for the C# syntax.)

1
2
3
4
5
6
7
8
9
10
static class MyDictionary<T>
{
  public static List<List<T>> Value;
}

// add to dictionary
MyDictionary<int>.Value = new List<List<int>>();

// access dictionary
if(MyDictionary<string>.Value != null) { ... }
By on 1/5/2009 10:17 PM ()

For example you cant store an int mapping over to a List<List<int>>, and also a string over to a List<List<string>> in the same dictionary. Static typing does not allow this without casting to obj or somelike that.
If you use a discriminated union for the type it will minimize your types options but it win't force the key to be of same type as the container.

By on 1/5/2009 1:26 PM ()

Strongly typed heterogeneous collections seem to be possible.

I'm a novice in this area, but I think we would need higher-kinded types and abstractions like type classes.

Here is some chatter on the topic for C# and scala

For now I just want to find my way to a solution that is the least bad. :-)

By on 1/5/2009 1:50 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper