aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorEduardo Julian2019-04-17 19:27:25 -0400
committerEduardo Julian2019-04-17 19:27:25 -0400
commit797e49a906d850d28d94986c127a8e432ea89e40 (patch)
tree3d1758d42a7612cdb0a167eb680cb3f8718a7c29 /stdlib
parentc501d1357241df39573893d9b6dbcf44a22f4554 (diff)
Order for names.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/source/lux/data/name.lux19
1 files changed, 19 insertions, 0 deletions
diff --git a/stdlib/source/lux/data/name.lux b/stdlib/source/lux/data/name.lux
index b54988169..3ad96cd84 100644
--- a/stdlib/source/lux/data/name.lux
+++ b/stdlib/source/lux/data/name.lux
@@ -3,6 +3,7 @@
[abstract
[monoid (#+)]
[equivalence (#+ Equivalence)]
+ [order (#+ Order)]
[codec (#+ Codec)]
hash]
[data
@@ -25,6 +26,24 @@
(and (text@= xmodule ymodule)
(text@= xname yname))))
+(def: (name@< [moduleP shortP] [moduleS shortS])
+ (-> Name Name Bit)
+ (if (text@= moduleP moduleS)
+ (:: text.order < shortP shortS)
+ (:: text.order < moduleP moduleS)))
+
+(structure: #export order (Order Name)
+ (def: &equivalence ..equivalence)
+ (def: < name@<)
+ (def: (<= parameter subject)
+ (or (:: ..equivalence = parameter subject)
+ (name@< parameter subject)))
+ (def: (> parameter subject)
+ (name@< subject parameter))
+ (def: (>= parameter subject)
+ (or (:: ..equivalence = subject parameter)
+ (name@< subject parameter))))
+
(structure: #export codec (Codec Text Name)
(def: (encode [module short])
(case module