(.module: [lux #* [control [equivalence (#+ Equivalence)] [codec (#+ Codec)] hash] [data ["." text ("text/." Monoid Hash)]]]) ## [Types] ## (type: Name ## [Text Text]) ## [Functions] (do-template [ ] [(def: #export ( [module short]) (-> Name Text) )] [module module] [short short] ) ## [Structures] (structure: #export _ (Equivalence Name) (def: (= [xmodule xname] [ymodule yname]) (and (text/= xmodule ymodule) (text/= xname yname)))) (structure: #export _ (Codec Text Name) (def: (encode [module short]) (case module "" short _ ($_ text/compose module "." short))) (def: (decode input) (if (text/= "" input) (#.Left (text/compose "Invalid format for Name: " input)) (case (text.split-all-with "." input) (^ (list short)) (#.Right ["" short]) (^ (list module short)) (#.Right [module short]) _ (#.Left (text/compose "Invalid format for Name: " input)))))) (structure: #export _ (Hash Name) (def: eq Equivalence) (def: (hash [module name]) (n/+ (text/hash module) (text/hash name))))