aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/debug.lux
blob: 91fc034f959a3f8109c11cee858ff54ea2344906 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
(.using
 [library
  [lux (.except private)
   ["$" documentation (.only documentation:)]
   [data
    ["[0]" text (.only \n)
     ["%" \\format (.only format)]]]
   [macro
    ["[0]" template]]]]
 [\\library
  ["[0]" /]])

(documentation: /.inspection
  "A best-effort attempt to generate a textual representation of a value, without knowing its type."
  [(inspection value)])

(documentation: /.representation
  "A best-effort attempt to generate a textual representation of a value, while knowing its type."
  [(representation type value)])

(documentation: /.private
  "Allows access to un-exported definitions in other modules."
  ["Module A"
   (def .private (secret_definition input)
     (-> ??? ???)
     (foo (bar (baz input))))
   "Module B"
   ((/.private secret_definition) my_input)])

(documentation: /.log!
  "Prints/writes a message to standard output."
  [(log! message)])

(documentation: /.hole
  (format "A typed 'hole'."
          \n "Reveals the type expected of the expression that should go in the hole.")
  [(is (-> Nat Text)
       (function (_ number)
         (hole)))
   "=>"
   .Text])

(documentation: /.here
  "Shows the names and values of local bindings available around the call to 'here'."
  [(let [foo 123
         bar +456
         baz +789.0]
     (is Any
         (here)))
   "=>"
   "foo: +123"
   "bar: +456"
   "baz: +789.0"
   []]
  ["Can optionally be given a list of definitions to focus on."
   "These definitions to focus on can include custom format to represent the values."
   (let [foo 123
         bar +456
         baz +789.0]
     (is Any
         (here [foo %.nat] baz)))
   "=>"
   "foo: 123"
   "baz: +789.0"
   []])

(.def .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..inspection
             ..representation
             ..private
             ..log!
             ..hole
             ..here
             ($.default /.cannot_represent_value)
             ($.default /.type_hole)
             ($.default /.unknown_local_binding)]
            []))