;;;; A generic conversion from an enum, licensed by {:where (enum? $t)}. enum? ;;;; admits exactly the enums and entails ordered? and equal?, so a body under ;;;; it may convert, compare and test for equality, at any enum. (defenum Color [red green blue]) (defenum Size [small 10 large 20]) (defn code [x $t] i32 {:where (enum? $t)} (i32 x)) (defn later? [a $t b $t] bool {:where (enum? $t)} (> a b)) (defn same? [a $t b $t] bool {:where (enum? $t)} (and (= a b) (<= a b))) (defn main [] i32 (let [c (Color 2) s (Size 20)] (println (code c)) ; 2 (println (code s)) ; 20 (println (later? c (Color 0))) ; true (println (same? (Color 1) (Color 1))) ; true (println (f64 (code s)))) ; 20 0)