aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/abstract/predicate.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/library/lux/abstract/predicate.lux17
1 files changed, 14 insertions, 3 deletions
diff --git a/stdlib/source/library/lux/abstract/predicate.lux b/stdlib/source/library/lux/abstract/predicate.lux
index 205ccc316..d53a9a3cb 100644
--- a/stdlib/source/library/lux/abstract/predicate.lux
+++ b/stdlib/source/library/lux/abstract/predicate.lux
@@ -9,21 +9,29 @@
["." contravariant]]])
(type: #export (Predicate a)
+ {#.doc (doc "A question that can be asked of a value, yield either false (#0) or true (#1).")}
(-> a Bit))
-(template [<identity_name> <identity_value> <composition_name> <composition>]
+(template [<identity_name> <identity_value> <composition_name> <composition>
+ <identity_doc> <composition_doc>]
[(def: #export <identity_name>
+ {#.doc <identity_doc>}
Predicate
(function.constant <identity_value>))
(def: #export (<composition_name> left right)
+ {#.doc <composition_doc>}
(All [a] (-> (Predicate a) (Predicate a) (Predicate a)))
(function (_ value)
(<composition> (left value)
(right value))))]
- [none #0 unite or]
- [all #1 intersect and]
+ [none #0 unite or
+ (doc "A predicate that always fails.")
+ (doc "A predicate that meets either predecessor.")]
+ [all #1 intersect and
+ (doc "A predicate that always succeeds.")
+ (doc "A predicate that meets both predecessors.")]
)
(template [<name> <identity> <composition>]
@@ -38,16 +46,19 @@
)
(def: #export (complement predicate)
+ {#.doc (doc "The opposite of a predicate.")}
(All [a] (-> (Predicate a) (Predicate a)))
(|>> predicate not))
(def: #export (difference sub base)
+ {#.doc (doc "A predicate that meeds 'base', but not 'sub'.")}
(All [a] (-> (Predicate a) (Predicate a) (Predicate a)))
(function (_ value)
(and (base value)
(not (sub value)))))
(def: #export (rec predicate)
+ {#.doc (doc "Ties the knot for a recursive predicate.")}
(All [a]
(-> (-> (Predicate a) (Predicate a))
(Predicate a)))