aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/cache/influences.lux
blob: bbddd79aa5b52e9df8a70185973b7df0bf6b3c0d (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
(.module:
  lux
  (lux (data [text]
             (coll [list "list/" Fold<List>]
                   (dictionary ["dict" unordered #+ Dict])))))

(type: #export Influences (Dict Text (List Text)))

(def: #export (track to from)
  (-> Text Text Influences Influences)
  (|>> (dict.update~ from (list) (|>> (#.Cons to)))
       (dict.update~ to (list) id)))

(def: (effluents module influences)
  (-> Text Influences (Maybe (List Text)))
  (dict.get module influences))

(def: #export (untrack module influences)
  (-> Text Influences Influences)
  (case (effluents module influences)
    (#.Some effluents)
    (list/fold untrack (dict.remove module influences) effluents)

    #.None
    influences))

(def: #export empty Influences (dict.new text.Hash<Text>))