aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/control/region.lux
blob: 26e9f23323c62c13cff0601389495a9275014430 (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
(.using
 [library
  [lux (.except if loop)
   ["$" documentation (.only documentation:)]
   [data
    [text (.only \n)
     ["%" \\format (.only format)]]]
   [macro
    ["[0]" template]]]]
 [\\library
  ["[0]" /]])

(documentation: (/.Region r ! it)
  (format "A region where resources may be be claimed and where a side-effecting computation may be performed."
          \n "Every resource is paired with a function that knows how to clean/reclaim it, to make sure there are no leaks."))

(documentation: /.run!
  "Executes a region-based computation, with a side-effect determined by the monad."
  [(run! monad computation)])

(documentation: /.acquire!
  "Acquire a resource while pairing it a function that knows how to reclaim it."
  [(acquire! monad cleaner value)])

(documentation: /.failure
  "Immediately fail with this 'message'."
  [(failure monad error)])

(documentation: /.except
  "Fail by throwing/raising an exception."
  [(except monad exception message)])

(documentation: /.lifted
  "Lift an effectful computation into a region-based computation."
  [(lifted monad operation)])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..Region
             ..run!
             ..acquire!
             ..failure
             ..except
             ..lifted
             ($.default /.clean_up_error)
             ($.default /.functor)
             ($.default /.apply)
             ($.default /.monad)]
            []))