aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/control/security/taint.lux
blob: afdc1904cad82e5b613e51a99bcaef5eef42159b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
(.module:
  [lux #*
   [control
    [functor (#+ Functor)]
    [apply (#+ Apply)]
    [monad (#+ Monad)]]
   [data
    [error (#+ Error)]]
   [type
    abstract]])

(abstract: #export (Dirty a)
  a

  (def: #export taint
    (All [a] (-> a (Dirty a)))
    (|>> :abstraction))

  (def: #export (validate validator dirty)
    (All [a b] (-> (-> a (Error b)) (Dirty a) (Error b)))
    (validator (:representation dirty)))

  (def: #export trust
    (All [a] (-> (Dirty a) a))
    (|>> :representation))

  (structure: #export _ (Functor Dirty)
    (def: (map f fa)
      (|> fa :representation f :abstraction)))

  (structure: #export _ (Apply Dirty)
    (def: functor Functor<Dirty>)

    (def: (apply ff fa)
      (:abstraction ((:representation ff) (:representation fa)))))

  (structure: #export _ (Monad Dirty)
    (def: functor Functor<Dirty>)

    (def: wrap (|>> :abstraction))

    (def: join (|>> :representation)))
  )