Fork me on GitHub
#core-typed
<
2024-03-27
>
TJ Campanella18:03:59

Whats the best way to define an enum? I was trying something like this but I don't think you can use t/Val like this. I also tried t/Str but that doesn't seem to work either.

(t/defalias Role (t/U (t/Val "role1")
                      (t/Val "role2")
                      (t/Val "role3")
                      (t/Val "role4")))

ambrosebs18:03:29

Should be able to quote the string value for a singleton type.

ambrosebs18:03:32

But that does the same thing as t/Val

ambrosebs18:03:41

what's the issue?

TJ Campanella19:03:47

I'm using the pred function on a HMap type that has a Role as one of the values and it is saying it cannot generate predicate for value type: role1

TJ Campanella19:03:16

Using a Role type as shown above nested in a HMap as a value for a :role key

ambrosebs01:03:07

I will add a case for it.

ambrosebs02:03:02

t/Str works for me, could not reproduce?

TJ Campanella00:03:02

Ok cool I’ll try it again

TJ Campanella15:03:41

Were you able to do it like this?

(t/defalias Role (t/U (t/Str "role1")
                      (t/Str "role2")
                      (t/Str "role3")
                      (t/Str "role4")))
If not what did you mean when you said t/Str works for you?

ambrosebs16:03:52

Oh, no I meant just (t/defalias Role t/Str) .

ambrosebs16:03:14

(t/Val "role1") should work now.

TJ Campanella16:03:38

Ah ok let me try

TJ Campanella16:03:04

Works perfectly now thanks!

🎉 1