aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/control/region.lux
blob: 08e8177b942f2b5bf1c223c4caa07d6effa219a8 (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
(.module:
  [library
   [lux (#- if loop)
    ["$" documentation (#+ documentation:)]
    [data
     [text (#+ \n)
      ["%" format (#+ format)]]]
    [macro
     ["." template]]]]
  [\\library
   ["." /]])

(documentation: /.Region
  (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)]
            []))