aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/control/thread.lux
blob: bc4062c107324ba2d7d5d513897261cc1b3f6246 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
(.using
 [library
  [lux (.except local)
   ["$" documentation (.only documentation:)]
   [data
    [text (.only \n)
     ["%" \\format (.only format)]]]
   [macro
    ["[0]" template]]]]
 [\\library
  ["[0]" /]])

(documentation: (/.Thread ! it)
  "An imperative process with access to mutable values.")

(documentation: (/.Box ! it)
  "A mutable box holding a value.")

(documentation: /.box
  "A brand-new box initialized to the given value."
  [(box init)])

(documentation: /.read!
  "Reads the current value in the box."
  [(read! box)])

(documentation: /.write!
  "Mutates the value in the box."
  [(write! value box)])

(documentation: /.result
  "Executes the imperative thread in a self-contained way."
  [(result thread)])

(documentation: /.io
  "Transforms the imperative thread into an I/O computation.")

(documentation: /.update!
  "Update a box's value by applying a function to it."
  [(update! f box)])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..Thread
             ..Box
             ..box
             ..read!
             ..write!
             ..result
             ..io
             ..update!
             ($.default /.functor)
             ($.default /.apply)
             ($.default /.monad)]
            []))