You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the types for all generated versions are nominally different, even if they are structurally the same.
Let's say that we have two atd files:
type person = {
name: string;
surname: string
}
type employee = {
person: person;
age: int
}
and
type person = {
name: string;
surname: string
}
type employee = {
person: person;
age: int;
+ title: string
}
The type person stays the same between both files (it's not even transitively modified). Currently this generates two types Version1.person and Version2.person. They are structurally the same but nominally different. Behind the scenes %identity is used to transform one to the other.
This has two cons:
Less important: the implementation of stork doesn't leverage OCaml type checker as a sort of proof mechanism
More important: When you write migrators there's a lot of repetition for nested fields (i.e. you have to run migrate on them even if they didn't change). e.g.:
let convert_employee converter doc (from: OldVersion.employee): NewVersion.employee = {
person = converter.convert_person converter doc from.person;
age = from.age;
title = "IC"
}
instead of
let convert_employee converter doc (from: OldVersion.employee): NewVersion.employee = {
person = from.person;
age = from.age;
title = "IC"
}
The text was updated successfully, but these errors were encountered:
Solving this issue would require either hacking around or using atd as a library rather than as a binary. Notably it already includes a way to mark fields as aliases to generate code like type person = OldVersion.person = { ... } (if the alias was set to OldVersion)
Currently the types for all generated versions are nominally different, even if they are structurally the same.
Let's say that we have two atd files:
and
type person = { name: string; surname: string } type employee = { person: person; age: int; + title: string }
The type person stays the same between both files (it's not even transitively modified). Currently this generates two types Version1.person and Version2.person. They are structurally the same but nominally different. Behind the scenes
%identity
is used to transform one to the other.This has two cons:
instead of
The text was updated successfully, but these errors were encountered: