## Stronger relationships between structures

Lets say you're compiler uses the following structures to represent a function type and a class to represent a function declaration:

class FuncType extends Type {
List<Type> params;
Type ret;
}

class FuncDecl {
String name;
FuncType type;
List<String> paramNames;
}


There objects "FuncDecl.type.params" and "FuncDecl.paramNames" are related in ways that aren't expressed in the source code of the two class declarations. For example, each entry in the "paramNames" list matches up with the corresponding type in the "type.params" list.

I've been thinking about "paramNames" as adding attributes to the "FuncType" data structure. So paramNames would actually be a "map" data structure whose keys are structural references to parameter types and whose values are strings. Something like:

class FuncDecl {
String name;
FuncType type;
Map<#type#,String> paramNames;
}
FuncDecl d = ...;
d.paramNames.put(#params[0]#", "dst");  // The "params" refers to the list in "type"
d.paramNames.put(#params[1]#", "src");
...


The best concrete solution I can come up with isn't satisfying:

class FuncType<ExtraParamInfo,ExtraReturnInfo> {
List<Pair<Type,ExtraParamInfo>> paramets;
Pair<Type,ExtraReturnInfo> ret;
}

class FuncDecl {
Type<String,Void> typeAndParamNames;
}


Is there a language or type system that does a good job of expressing such relationships?