aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/macro/syntax/input.lux
blob: 6d7d8c3577094a61f6aa15125820ee47b5f62691 (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
(.using
 [library
  [lux "*"
   [abstract
    [equivalence {"+" Equivalence}]]
   [control
    ["<>" parser
     ["<[0]>" code {"+" Parser}]]]
   [data
    ["[0]" product]
    [collection
     ["[0]" list ("[1]#[0]" monad)]]]
   [macro
    ["[0]" code]]]])

(type: .public Input
  (Record
   [#binding Code
    #type Code]))

(def: .public equivalence
  (Equivalence Input)
  ($_ product.equivalence
      code.equivalence
      code.equivalence
      ))

(def: .public format
  (-> (List Input) Code)
  (|>> (list#each (function (_ value)
                    (list (the #binding value)
                          (the #type value))))
       list#conjoint
       code.tuple))

(def: .public parser
  (Parser (List Input))
  (<| <code>.tuple
      <>.some
      ($_ <>.and
          <code>.any
          <code>.any
          )))