From 797e49a906d850d28d94986c127a8e432ea89e40 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 17 Apr 2019 19:27:25 -0400 Subject: Order for names. --- stdlib/source/lux/data/name.lux | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'stdlib') 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 -- cgit v1.2.3