The more complex case is (again, referring to commons-collections-15) a type I find in our code: Map<Class<?>,Transformer<? extends Object,String> - the intent is to provide a type-dispatch of (in this case) a toString() method, which was not necessarily provided by the original developer. Again, what one wants is the dependency between the argument and the returned value, that is: public <T> Transformer<T,String> get(Class<T> type).
The challenge is even to write a generic Map<?,?>-like interface such that by giving appropriate type parameters, the general class of such interdependencies can be expressed. Certainly, any particular case of interdependency can be written up as an explicit function. But can it be written in any popular language as a generic type, for example, by doing something with manipulating captured types in syntax? I'm interested in solutions in any language which permits the compiler to show (within reason) the correctness of the code.
[0] The fact that it can (kind of) be done in the C preprocessor suggests that it might be possible in C++, but I'm not the expert.
[1] Somebody please tell the world why Google reinvented that particular wheel?
Edit: Solutions in typed lambda calculus are fine. I haven't got that head on at the moment. Please explain whether or not this is a facility which is generally missing from the languages in question.