This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-27
Channels
- # beginners (29)
- # biff (4)
- # calva (3)
- # cider (5)
- # cljdoc (24)
- # clojure (40)
- # clojure-conj (6)
- # clojure-europe (17)
- # clojure-nl (1)
- # clojure-norway (20)
- # clojure-uk (10)
- # clojurescript (26)
- # core-typed (15)
- # cursive (8)
- # datomic (5)
- # figwheel-main (2)
- # honeysql (1)
- # hyperfiddle (78)
- # jobs-discuss (5)
- # joker (3)
- # malli (36)
- # missionary (18)
- # other-languages (9)
- # pedestal (7)
- # rdf (2)
- # shadow-cljs (6)
- # specter (4)
- # squint (12)
- # xtdb (7)
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")))
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
Using a Role type as shown above nested in a HMap as a value for a :role key
https://github.com/typedclojure/typedclojure/commit/ee089e1c738ed46af64f06147c8f20ee084bd391
Ok cool I’ll try it again
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?Ah ok let me try