diff options
author | Eduardo Julian | 2017-07-29 11:31:00 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-07-29 11:31:00 -0400 |
commit | f4d7431924312f16e4fbbd7343ca8d548582fded (patch) | |
tree | 3e2f97981582a229e0da3885c9876907a9e8e772 /stdlib | |
parent | f7047f1c3966bd1727c1a3729295def3c9913ab8 (diff) |
- Re-implemented Tainted using models.
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/source/lux/data/taint.lux | 25 | ||||
-rw-r--r-- | stdlib/source/lux/data/tainted.lux | 26 | ||||
-rw-r--r-- | stdlib/test/tests.lux | 3 |
3 files changed, 28 insertions, 26 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)) diff --git a/stdlib/test/tests.lux b/stdlib/test/tests.lux index a97229a10..6f593abff 100644 --- a/stdlib/test/tests.lux +++ b/stdlib/test/tests.lux @@ -73,7 +73,8 @@ ["_;" concatenative]) (data [env] [trace] - [store]) + [store] + [tainted]) [macro] (math [random]) (type [unit])) |