(.module: [lux #* [data ["." maybe] ["." text format]]]) (def: (sanitize char) (-> Nat Text) (case char (^ (char "*")) "_ASTER_" (^ (char "+")) "_PLUS_" (^ (char "-")) "_DASH_" (^ (char "/")) "_SLASH_" (^ (char "\\")) "_BSLASH_" (^ (char "_")) "_UNDERS_" (^ (char "%")) "_PERCENT_" (^ (char "$")) "_DOLLAR_" (^ (char "'")) "_QUOTE_" (^ (char "`")) "_BQUOTE_" (^ (char "@")) "_AT_" (^ (char "^")) "_CARET_" (^ (char "&")) "_AMPERS_" (^ (char "=")) "_EQ_" (^ (char "!")) "_BANG_" (^ (char "?")) "_QM_" (^ (char ":")) "_COLON_" (^ (char ".")) "_PERIOD_" (^ (char ",")) "_COMMA_" (^ (char "<")) "_LT_" (^ (char ">")) "_GT_" (^ (char "~")) "_TILDE_" (^ (char "|")) "_PIPE_" _ (text.from-code char))) (def: #export (normalize name) (-> Text Text) (let [name/size (text.size name)] (loop [idx 0 output ""] (if (n/< name/size idx) (recur (inc idx) (|> (text.nth idx name) maybe.assume sanitize (format output))) output)))) (def: #export (definition [module short]) (-> Name Text) (format (normalize module) "___" (normalize short)))