aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/meta/macro/syntax/input.lux
blob: 4461c7df90d870506ebe6e302d60a1021fa4062e (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
(.require
 [library
  [lux (.except)
   [abstract
    [equivalence (.only Equivalence)]]
   [control
    ["<>" parser]]
   [data
    ["[0]" product]
    [collection
     ["[0]" list (.use "[1]#[0]" monad)]]]
   [meta
    ["[0]" code (.only)
     ["<[1]>" \\parser (.only Parser)]]]]])

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

(def .public equivalence
  (Equivalence Input)
  (all 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
      (all <>.and
           <code>.any
           <code>.any
           )))