aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/module/descriptor/common.lux
diff options
context:
space:
mode:
Diffstat (limited to 'new-luxc/source/luxc/module/descriptor/common.lux')
-rw-r--r--new-luxc/source/luxc/module/descriptor/common.lux38
1 files changed, 38 insertions, 0 deletions
diff --git a/new-luxc/source/luxc/module/descriptor/common.lux b/new-luxc/source/luxc/module/descriptor/common.lux
new file mode 100644
index 000000000..60a313115
--- /dev/null
+++ b/new-luxc/source/luxc/module/descriptor/common.lux
@@ -0,0 +1,38 @@
+(;module:
+ lux
+ (lux (data [text]
+ (text format
+ ["l" lexer "l/" Monad<Lexer>])
+ [char]
+ (coll [list "L/" Functor<List>]))))
+
+(type: #export Signal Text)
+
+(do-template [<name> <code>]
+ [(def: #export <name> Signal (|> <code> char;char char;as-text))]
+
+ [cons-signal +5]
+ [nil-signal +6]
+ [stop-signal +7]
+ )
+
+(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))))
+