aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/module/descriptor/common.lux
blob: aac438a6fef1700378d20491bd43dca814c40730 (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
(;module:
  lux
  (lux (data [text]
             (text format
                   ["l" lexer "l/" Monad<Lexer>])
             (coll [list "L/" Functor<List>]))))

(type: #export Signal Text)

(do-template [<name> <code>]
  [(def: #export <name> Signal <code>)]

  [cons-signal "\u0005"]
  [nil-signal  "\u0006"]
  [stop-signal "\u0007"]
  )

(do-template [<name> <code>]
  [(def: #export <name> Signal <code>)]

  [ident-separator ";"]
  )

(def: #export (encode-list encode-elem types)
  (All [a] (-> (-> a Text) (List a) Text))
  (format (|> (L/map encode-elem types)
              (text;join-with cons-signal))
          nil-signal))

(def: #export (decode-list decode-elem)
  (All [a] (-> (l;Lexer a) (l;Lexer (List a))))
  (l;alt (<| (l;after (l;text nil-signal))
             (l/wrap []))
         (<| (l;seq decode-elem)
             (l;after (l;text cons-signal))
             (decode-list decode-elem))))