aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source')
-rw-r--r--stdlib/source/lux/data/taint.lux25
-rw-r--r--stdlib/source/lux/data/tainted.lux26
2 files changed, 26 insertions, 25 deletions
diff --git a/stdlib/source/lux/data/taint.lux b/stdlib/source/lux/data/taint.lux
deleted file mode 100644
index d78b9a52a..000000000
--- a/stdlib/source/lux/data/taint.lux
+++ /dev/null
@@ -1,25 +0,0 @@
-(;module:
- lux
- (lux (data [product])))
-
-(type: #export (Tainted a)
- [a Void])
-
-(def: #export (taint input)
- (All [a] (-> a (Tainted a)))
- [input (:! Void [])])
-
-(def: #export (trust input)
- (All [a] (-> (Tainted a) a))
- (product;left input))
-
-(def: #export (validate pred input)
- (All [a] (-> (-> a Bool) (Tainted a) (Maybe a)))
- (let [value (product;left input)]
- (if (pred value)
- (#;Some value)
- #;None)))
-
-(def: #export (sanitize f input)
- (All [a] (-> (-> a a) (Tainted a) a))
- (|> input product;left f))
diff --git a/stdlib/source/lux/data/tainted.lux b/stdlib/source/lux/data/tainted.lux
new file mode 100644
index 000000000..9060d1da5
--- /dev/null
+++ b/stdlib/source/lux/data/tainted.lux
@@ -0,0 +1,26 @@
+(;module:
+ lux
+ (lux (data [product])
+ (type model)))
+
+(model: #export (Tainted a)
+ a
+
+ (def: #export taint
+ (All [a] (-> a (Tainted a)))
+ (|>. @model))
+
+ (def: #export trust
+ (All [a] (-> (Tainted a) a))
+ (|>. @repr)))
+
+(def: #export (validate pred tainted)
+ (All [a] (-> (-> a Bool) (Tainted a) (Maybe a)))
+ (let [value (trust tainted)]
+ (if (pred value)
+ (#;Some value)
+ #;None)))
+
+(def: #export (sanitize f tainted)
+ (All [a] (-> (-> a a) (Tainted a) a))
+ (|> tainted trust f))