By “directly” I mean without first creating a Map<T, Unit> or similar.
So far I was only able to do this indirectly:
TypeScript:
let attributesMap : damlTypes.Map<BookAttribute, {}> = damlTypes.emptyMap();
let pages: BookAttribute = {tag: "Pages", value: "104"};
attributesMap = attributesMap.set(pages, {});
let authors: BookAttribute = {tag: "Authors", value: ["Lewis Carroll", "John Tenniel"]};
attributesMap = attributesMap.set(authors, {});
let title: BookAttribute = {tag: "Title", value: "Alice's Adventures in Wonderland"};
attributesMap = attributesMap.set(title, {});
let published: BookAttribute = {tag: "Published", value: {year: "1865", publisher: "Macmillan"}};
attributesMap = attributesMap.set(published, {});
let attributes : Set<BookAttribute> = { map : attributesMap };
Java:
Pages pages = new Pages(104L);
Authors authors = new Authors(List.of("Lewis Carroll", "John Tenniel"));
Title title = new Title("Alice's Adventures in Wonderland");
Published published = new Published(1865L, "Macmillan");
Isbn isbn = new Isbn("9780440000754");
Map<BookAttribute, Unit> attribuesMap = Map.of(
pages, Unit.getInstance(),
authors, Unit.getInstance(),
title, Unit.getInstance(),
published, Unit.getInstance(),
isbn, Unit.getInstance()
);
Set<BookAttribute> attributes = new Set<>(attribuesMap);
Am I missing something?