aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/type/refinement.lux
blob: 008f64e82940deea2392e82fb59b45e84ba24249 (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
(.using
  [library
   [lux {"-" type}
    ["$" documentation {"+" documentation:}]
    [control
     ["<>" parser
      ["<[0]>" code]]]
    [data
     ["[0]" text {"+" \n}
      ["%" format {"+" format}]]]
    [macro
     ["[0]" template]]]]
  [\\library
   ["[0]" /]])

(documentation: (/.Refined it)
  "A refined version of another type, using a predicate to select valid instances.")

(documentation: (/.Refiner it)
  "A selection mechanism for refined instances of a type.")

(documentation: /.refiner
  ""
  [(refiner predicate)])

(documentation: /.lifted
  (format "Yields a function that can work on refined values."
          \n "Respects the constraints of the refinement.")
  [(lifted transform)])

(documentation: /.only
  ""
  [(only refiner values)])

(documentation: /.partition
  "Separates refined values from the un-refined ones."
  [(partition refiner values)])

(documentation: /.type
  "The Refined type associated with a Refiner type."
  [(def: even
     (refiner even?))

   (def: Even
     Type
     (type even))

   (: (Maybe Even)
      (even 123))])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..Refined
             ..Refiner
             ..refiner
             ..lifted
             ..only
             ..partition
             ..type
             ($.default /.value)
             ($.default /.predicate)]
            []))