What is the reason for have a types such as Set vs using the languages built in format?
This is done so that the relationship between Daml[-LF] and the codegen output is less “magical”. That is, type definitions in Daml are always reflected in a generated record or variant class generated in exactly the same shape as any other record or variant class.
Only LF primitives may receive special treatment, and this treatment needs to be carefully considered. Without expanding too much detail, I can safely say, for example, that we would not choose java.util.Set
as the expansion if set was an LF primitive.
We considered for Scala codegen, and rejected, the idea of “detecting” or special-casing codegen choices for Daml type definitions; this decision carries over to Java codegen.
Thanks for the details! Very clear.
Why this question came up was when working with these special types, there is serialization factors: such as how to serialize a Daml “Set”, which really means conversion of Daml Set into java set.
Would be very helpful to provide adapter utils to convert from the special Daml types into the lang types. Example Daml Set is a Set<Map<K, Unit>> which turns into more de/serialization complexities for each application impl.