(.module: [lux #*] [// ["." order (#+ Order)]]) (signature: #export (Enum e) {#.doc "Enumerable types, with a notion of moving forward and backwards through a type's instances."} (: (Order e) &order) (: (-> e e) succ) (: (-> e e) pred)) (def: (range' <= succ from to) (All [a] (-> (-> a a Bit) (-> a a) a a (List a))) (if (<= to from) (#.Cons from (range' <= succ (succ from) to)) #.Nil)) (def: #export (range (^open ",@.") from to) {#.doc "An inclusive [from, to] range of values."} (All [a] (-> (Enum a) a a (List a))) (range' (order.<= ,@&order) ,@succ from to))