From d89d837de3475b75587a4293e094d755d2cd4626 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 17 Nov 2020 20:23:53 -0400 Subject: Made the syntax of ^template more consistent. --- stdlib/source/poly/lux/abstract/equivalence.lux | 34 ++--- stdlib/source/poly/lux/data/format/json.lux | 162 ++++++++++++------------ 2 files changed, 98 insertions(+), 98 deletions(-) (limited to 'stdlib/source/poly') diff --git a/stdlib/source/poly/lux/abstract/equivalence.lux b/stdlib/source/poly/lux/abstract/equivalence.lux index a4d139aa4..0f5db0309 100644 --- a/stdlib/source/poly/lux/abstract/equivalence.lux +++ b/stdlib/source/poly/lux/abstract/equivalence.lux @@ -11,14 +11,14 @@ ["." bit] ["." maybe] [number - ["." nat ("#//." decimal)] + ["." nat ("#\." decimal)] ["." int] ["." rev] ["." frac]] - ["." text ("#//." monoid) + ["." text ("#\." monoid) ["%" format (#+ format)]] [collection - ["." list ("#//." monad)] + ["." list ("#\." monad)] ["." row] ["." array] ["." queue] @@ -115,15 +115,15 @@ (wrap (` (: (~ (@Equivalence inputT)) (function ((~ g!_) (~ g!left) (~ g!right)) (case [(~ g!left) (~ g!right)] - (~+ (list//join (list//map (function (_ [tag g!eq]) - (if (nat.= last tag) - (list (` [((~ (code.nat (dec tag))) #1 (~ g!left)) - ((~ (code.nat (dec tag))) #1 (~ g!right))]) - (` ((~ g!eq) (~ g!left) (~ g!right)))) - (list (` [((~ (code.nat tag)) #0 (~ g!left)) - ((~ (code.nat tag)) #0 (~ g!right))]) - (` ((~ g!eq) (~ g!left) (~ g!right)))))) - (list.enumeration members)))) + (~+ (list\join (list\map (function (_ [tag g!eq]) + (if (nat.= last tag) + (list (` [((~ (code.nat (dec tag))) #1 (~ g!left)) + ((~ (code.nat (dec tag))) #1 (~ g!right))]) + (` ((~ g!eq) (~ g!left) (~ g!right)))) + (list (` [((~ (code.nat tag)) #0 (~ g!left)) + ((~ (code.nat tag)) #0 (~ g!right))]) + (` ((~ g!eq) (~ g!left) (~ g!right)))))) + (list.enumeration members)))) (~ g!_) #0)))))) ## Tuples @@ -131,13 +131,13 @@ [g!eqs (.tuple (p.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) - g!rights (list//map (|>> nat//encode (text//compose "right") code.local-identifier) indices)]] + g!lefts (list\map (|>> nat\encode (text\compose "left") code.local-identifier) indices) + g!rights (list\map (|>> nat\encode (text\compose "right") code.local-identifier) indices)]] (wrap (` (: (~ (@Equivalence inputT)) (function ((~ g!_) [(~+ g!lefts)] [(~+ g!rights)]) (and (~+ (|> (list.zip/3 g!eqs g!lefts g!rights) - (list//map (function (_ [g!eq g!left g!right]) - (` ((~ g!eq) (~ g!left) (~ g!right))))))))))))) + (list\map (function (_ [g!eq g!left g!right]) + (` ((~ g!eq) (~ g!left) (~ g!right))))))))))))) ## Type recursion (do ! [[g!self bodyC] (.recursive equivalence) @@ -156,7 +156,7 @@ (do ! [[funcC varsC bodyC] (.polymorphic equivalence)] (wrap (` (: (All [(~+ varsC)] - (-> (~+ (list//map (|>> (~) ((~! /.Equivalence)) (`)) varsC)) + (-> (~+ (list\map (|>> (~) ((~! /.Equivalence)) (`)) varsC)) ((~! /.Equivalence) ((~ (poly.to-code *env* inputT)) (~+ varsC))))) (function ((~ funcC) (~+ varsC)) (~ bodyC)))))) diff --git a/stdlib/source/poly/lux/data/format/json.lux b/stdlib/source/poly/lux/data/format/json.lux index afe34c404..15c8c5906 100644 --- a/stdlib/source/poly/lux/data/format/json.lux +++ b/stdlib/source/poly/lux/data/format/json.lux @@ -18,14 +18,14 @@ ["." product] [number ["." i64] - ["n" nat ("#//." decimal)] + ["n" nat ("#\." decimal)] ["." int] - ["." frac ("#//." decimal)]] - ["." text ("#//." equivalence) + ["." frac ("#\." decimal)]] + ["." text ("#\." equivalence) ["%" format (#+ format)]] [collection - ["." list ("#//." fold monad)] - ["." row (#+ Row row) ("#//." monad)] + ["." list ("#\." fold monad)] + ["." row (#+ Row row) ("#\." monad)] ["d" dictionary]]] [time ## ["." instant] @@ -96,13 +96,13 @@ (def: decode (|>> (:: ..int-codec decode) (:: e.functor map unit.in)))) -(poly: #export codec//encode +(poly: #export codec\encode (with-expansions [ (template [ ] [(do ! [#let [g!_ (code.local-identifier "_______")] _ ] - (wrap (` (: (~ (@JSON//encode inputT)) + (wrap (` (: (~ (@JSON\encode inputT)) ))))] [(.exactly Any) (function ((~ g!_) (~ (code.identifier ["" "0"]))) #/.Null)] @@ -114,7 +114,7 @@