aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/control/function.lux
blob: 0dac18b263cf45740446a3d445ca6722099d28ab (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
(.using
 [library
  [lux {"-" if loop}
   ["$" documentation (.only documentation:)]
   [data
    [text (.only \n)
     ["%" format (.only format)]]]
   [macro
    ["[0]" template]]]]
 [\\library
  ["[0]" /]]
 ["[0]" / "_"
  ["[1][0]" contract]
  ["[1][0]" memo]
  ["[1][0]" mixin]
  ["[1][0]" mutual]])

(documentation: /.identity
  (format "Identity function."
          \n "Does nothing to its argument and just returns it.")
  [(same? (identity value)
          value)])

(documentation: /.composite
  "Function composition."
  [(= ((composite f g) "foo")
      (f (g "foo")))])

(documentation: /.constant
  "Create constant functions."
  [(= ((constant "foo") "bar")
      "foo")])

(documentation: /.flipped
  "Flips the order of the arguments of a function."
  [(= ((flipped f) "foo" "bar")
      (f "bar" "foo"))])

(documentation: /.on
  "Simple 1-argument function application."
  [(on input function)])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..identity
             ..composite
             ..constant
             ..flipped
             ..on
             ($.default /.monoid)]
            [/contract.documentation
             /memo.documentation
             /mixin.documentation
             /mutual.documentation]))