diff options
author | Eduardo Julian | 2021-07-25 03:12:17 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-07-25 03:12:17 -0400 |
commit | 62b3abfcc014ca1c19d62aacdd497f6a250b372c (patch) | |
tree | c23155ecef6018b78b349f0ba6cd238872b24da7 /stdlib/source/poly | |
parent | 0f545b7e57d2564e351d907befd2ce26900c5521 (diff) |
Better syntax for "library/lux.^multi".
Diffstat (limited to 'stdlib/source/poly')
-rw-r--r-- | stdlib/source/poly/lux/abstract/equivalence.lux | 33 | ||||
-rw-r--r-- | stdlib/source/poly/lux/data/format/json.lux | 52 |
2 files changed, 42 insertions, 43 deletions
diff --git a/stdlib/source/poly/lux/abstract/equivalence.lux b/stdlib/source/poly/lux/abstract/equivalence.lux index 080e64af0..15795ffcf 100644 --- a/stdlib/source/poly/lux/abstract/equivalence.lux +++ b/stdlib/source/poly/lux/abstract/equivalence.lux @@ -4,9 +4,8 @@ [abstract [monad (#+ Monad do)]] [control - ["p" parser - ["<.>" type] - ["s" code (#+ Parser)]]] + ["<>" parser + ["<.>" type]]] [data ["." product] ["." bit] @@ -43,14 +42,14 @@ ["." /]]) (poly: #export equivalence - (`` (do {! p.monad} + (`` (do {! <>.monad} [#let [g!_ (code.local_identifier "_____________")] *env* <type>.env inputT <type>.peek #let [@Equivalence (: (-> Type Code) (function (_ type) (` ((~! /.Equivalence) (~ (poly.to_code *env* type))))))]] - ($_ p.either + ($_ <>.either ## Basic types (~~ (template [<matcher> <eq>] [(do ! @@ -68,8 +67,8 @@ ## Composite types (~~ (template [<name> <eq>] [(do ! - [[_ argC] (<type>.apply (p.and (<type>.exactly <name>) - equivalence))] + [[_ argC] (<type>.applied (<>.and (<type>.exactly <name>) + equivalence))] (wrap (` (: (~ (@Equivalence inputT)) (<eq> (~ argC))))))] @@ -82,10 +81,10 @@ [tree.Tree (~! tree.equivalence)] )) (do ! - [[_ _ valC] (<type>.apply ($_ p.and - (<type>.exactly dictionary.Dictionary) - <type>.any - equivalence))] + [[_ _ valC] (<type>.applied ($_ <>.and + (<type>.exactly dictionary.Dictionary) + <type>.any + equivalence))] (wrap (` (: (~ (@Equivalence inputT)) ((~! dictionary.equivalence) (~ valC)))))) ## Models @@ -102,13 +101,13 @@ [month.Month month.equivalence] )) (do ! - [_ (<type>.apply (p.and (<type>.exactly unit.Qty) - <type>.any))] + [_ (<type>.applied (<>.and (<type>.exactly unit.Qty) + <type>.any))] (wrap (` (: (~ (@Equivalence inputT)) unit.equivalence)))) ## Variants (do ! - [members (<type>.variant (p.many equivalence)) + [members (<type>.variant (<>.many equivalence)) #let [last (dec (list.size members)) g!_ (code.local_identifier "_____________") g!left (code.local_identifier "_____________left") @@ -129,7 +128,7 @@ #0)))))) ## Tuples (do ! - [g!eqs (<type>.tuple (p.many equivalence)) + [g!eqs (<type>.tuple (<>.many equivalence)) #let [g!_ (code.local_identifier "_____________") indices (list.indices (list.size g!eqs)) g!lefts (list\map (|>> nat\encode (text\compose "left") code.local_identifier) indices) @@ -149,7 +148,7 @@ <type>.recursive_self ## Type applications (do ! - [[funcC argsC] (<type>.apply (p.and equivalence (p.many equivalence)))] + [[funcC argsC] (<type>.applied (<>.and equivalence (<>.many equivalence)))] (wrap (` ((~ funcC) (~+ argsC))))) ## Parameters <type>.parameter @@ -164,6 +163,6 @@ <type>.recursive_call ## If all else fails... (|> <type>.any - (\ ! map (|>> %.type (format "Cannot create Equivalence for: ") p.fail)) + (\ ! map (|>> %.type (format "Cannot create Equivalence for: ") <>.fail)) (\ ! join)) )))) diff --git a/stdlib/source/poly/lux/data/format/json.lux b/stdlib/source/poly/lux/data/format/json.lux index d7409df9f..5c63c58e1 100644 --- a/stdlib/source/poly/lux/data/format/json.lux +++ b/stdlib/source/poly/lux/data/format/json.lux @@ -135,36 +135,36 @@ <basic> <time> (do ! - [unitT (<type>.apply (<>.after (<type>.exactly unit.Qty) - <type>.any))] + [unitT (<type>.applied (<>.after (<type>.exactly unit.Qty) + <type>.any))] (wrap (` (: (~ (@JSON\encode inputT)) (\ (~! qty_codec) (~' encode)))))) (do ! [#let [g!_ (code.local_identifier "_______") g!key (code.local_identifier "_______key") g!val (code.local_identifier "_______val")] - [_ _ =val=] (<type>.apply ($_ <>.and - (<type>.exactly d.Dictionary) - (<type>.exactly .Text) - encode))] + [_ _ =val=] (<type>.applied ($_ <>.and + (<type>.exactly d.Dictionary) + (<type>.exactly .Text) + encode))] (wrap (` (: (~ (@JSON\encode inputT)) (|>> ((~! d.entries)) ((~! list\map) (function ((~ g!_) [(~ g!key) (~ g!val)]) [(~ g!key) ((~ =val=) (~ g!val))])) - ((~! d.from_list) (~! text.hash)) + ((~! d.of_list) (~! text.hash)) #/.Object))))) (do ! - [[_ =sub=] (<type>.apply ($_ <>.and - (<type>.exactly .Maybe) - encode))] + [[_ =sub=] (<type>.applied ($_ <>.and + (<type>.exactly .Maybe) + encode))] (wrap (` (: (~ (@JSON\encode inputT)) ((~! ..nullable) (~ =sub=)))))) (do ! - [[_ =sub=] (<type>.apply ($_ <>.and - (<type>.exactly .List) - encode))] + [[_ =sub=] (<type>.applied ($_ <>.and + (<type>.exactly .List) + encode))] (wrap (` (: (~ (@JSON\encode inputT)) - (|>> ((~! list\map) (~ =sub=)) ((~! row.from_list)) #/.Array))))) + (|>> ((~! list\map) (~ =sub=)) ((~! row.of_list)) #/.Array))))) (do ! [#let [g!_ (code.local_identifier "_______") g!input (code.local_identifier "_______input")] @@ -205,7 +205,7 @@ <type>.recursive_self ## Type applications (do ! - [partsC (<type>.apply (<>.many encode))] + [partsC (<type>.applied (<>.many encode))] (wrap (` ((~+ partsC))))) ## Polymorphism (do ! @@ -258,25 +258,25 @@ <basic> <time> (do ! - [unitT (<type>.apply (<>.after (<type>.exactly unit.Qty) - <type>.any))] + [unitT (<type>.applied (<>.after (<type>.exactly unit.Qty) + <type>.any))] (wrap (` (: (~ (@JSON\decode inputT)) ((~! <>.codec) (~! qty_codec) (~! </>.any)))))) (do ! - [[_ _ valC] (<type>.apply ($_ <>.and - (<type>.exactly d.Dictionary) - (<type>.exactly .Text) - decode))] + [[_ _ valC] (<type>.applied ($_ <>.and + (<type>.exactly d.Dictionary) + (<type>.exactly .Text) + decode))] (wrap (` (: (~ (@JSON\decode inputT)) ((~! </>.dictionary) (~ valC)))))) (do ! - [[_ subC] (<type>.apply (<>.and (<type>.exactly .Maybe) - decode))] + [[_ subC] (<type>.applied (<>.and (<type>.exactly .Maybe) + decode))] (wrap (` (: (~ (@JSON\decode inputT)) ((~! </>.nullable) (~ subC)))))) (do ! - [[_ subC] (<type>.apply (<>.and (<type>.exactly .List) - decode))] + [[_ subC] (<type>.applied (<>.and (<type>.exactly .List) + decode))] (wrap (` (: (~ (@JSON\decode inputT)) ((~! </>.array) ((~! <>.some) (~ subC))))))) (do ! @@ -309,7 +309,7 @@ <type>.recursive_self ## Type applications (do ! - [[funcC argsC] (<type>.apply (<>.and decode (<>.many decode)))] + [[funcC argsC] (<type>.applied (<>.and decode (<>.many decode)))] (wrap (` ((~ funcC) (~+ argsC))))) ## Polymorphism (do ! |