Could you show me examples for specifying set and enum data in Dazl?

I cannot see any hint for sets in the docs. For enums I can see this:
variants - dict containing a single key naming the specific constructor to use, and value as listed in this table

I was trying several ways, but always get errors.

Set & enums are pretty different. Set is a type defined in the Daml standard library. It’s not a builtin type in LF, it’s just a wrapper around Map k ().

Enums on the other hand are one of the 3 kinds of user-defined types in LF (the other two being records & variants). In Daml, they look just like any other ADT but none of the constructors have arguments. The docs for the Daml → LF translation show some examples.

1 Like

Thanks, could you show me examples for specifying these in Python for Dazl?

By enum I mean e.g.

data DayOfWeek = Mon | Tue | Wed | …

Maybe I’m confusing it with variant.

Oh sorry, I missed the dazl part of your question.Afaict, enums are just represented as strings, e.g., "Mon". I think you can also use a Mapping and it uses the key of that although that sounds just confusing and I’d avoid it.

As for sets, you should get the representation from a record wrapped around a Map k ().

1 Like

Thank you, Moritz.

Recording for posterity: if I have an enum and a field of type set of enums:

data DayOfWeek = Mon | Tue | Wed | Thu | Fri | Sat | Sun deriving (Eq, Show, Ord)
daysOfWeek : Set DayOfWeek

I can populate the field in Dazl like this:

params = {
            ...,
            'daysOfWeek': {'map': {'Mon': {}, 'Tue':{}}}
        }