Closed akoptelov closed 1 year ago
For example, consider the following definition. Note also that each of MinaBasePendingCoinbaseMerkleTreeVersionedStableV2
and MinaBasePendingCoinbaseStackIdStableV1
has similar indirection.
pub struct MinaBasePendingCoinbaseStableV2(
pub MinaBasePendingCoinbaseStableV2Poly<
MinaBasePendingCoinbaseMerkleTreeVersionedStableV2,
MinaBasePendingCoinbaseStackIdStableV1,
>,
);
pub struct MinaBasePendingCoinbaseStableV2Poly<Tree, StackId> {
pub tree: Tree,
pub pos_list: Vec<StackId>,
pub new_pos: StackId,
}
This should be more succinct and comprehensible:
pub struct MinaBasePendingCoinbaseStableV2 {
pub tree: MinaBasePendingCoinbaseMerkleTreeVersionedStableV2,
pub pos_list: Vec<MinaBasePendingCoinbaseStackIdStableV1>,
pub new_pos: MinaBasePendingCoinbaseStackIdStableV1,
}
An update on this task.
These are the main issues I'm struggling with:
venv
, mapping from type var name to a substitution expression. The issue is that that substitution can have type variables as well, and their names can (and very often do) collide with already existing ones. The current solution is to maintain a stack of such venv
s, and map each type variable to a pair of the substitution expression and the index of the venv
it should use.
Currently generated types closely follow OCaml structure, i.e. there's a separate type definition for polymorphic types and there's one for each type to be able to encode version. That makes much harder to understand data structure.
Ideally there should be a type in Rust corresponding only to non-polymorphic types, and
Versioned
definitions only for limited number of types (like top-level types).