From ec1f31b5a1492d5e0ab260397291d4449483bbd9 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 23 Aug 2021 02:30:53 -0400 Subject: The Python compiler can now be compiled by the new JVM compiler. --- stdlib/source/poly/lux/abstract/equivalence.lux | 4 +- stdlib/source/poly/lux/data/format/json.lux | 139 ++++++++++++------------ 2 files changed, 72 insertions(+), 71 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 bcb2574bc..bc633d1ed 100644 --- a/stdlib/source/poly/lux/abstract/equivalence.lux +++ b/stdlib/source/poly/lux/abstract/equivalence.lux @@ -131,8 +131,8 @@ [g!eqs (.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) - g!rights (list\map (|>> nat\encode (text\compose "right") code.local_identifier) indices)]] + g!lefts (list\map (|>> nat\encoded (text\compose "left") code.local_identifier) indices) + g!rights (list\map (|>> nat\encoded (text\compose "right") code.local_identifier) indices)]] (in (` (: (~ (@Equivalence inputT)) (function ((~ g!_) [(~+ g!lefts)] [(~+ g!rights)]) (and (~+ (|> (list.zipped/3 g!eqs g!lefts g!rights) diff --git a/stdlib/source/poly/lux/data/format/json.lux b/stdlib/source/poly/lux/data/format/json.lux index 1496026a7..be290d301 100644 --- a/stdlib/source/poly/lux/data/format/json.lux +++ b/stdlib/source/poly/lux/data/format/json.lux @@ -44,12 +44,12 @@ (-> Nat Frac) (|>> .int int.frac)) -(def: (rec_encode non_rec) +(def: (rec_encoded non_rec) (All [a] (-> (-> (-> a JSON) (-> a JSON)) (-> a JSON))) (function (_ input) - (non_rec (rec_encode non_rec) input))) + (non_rec (rec_encoded non_rec) input))) (def: low_mask Nat (|> 1 (i64.left_shifted 32) --)) (def: high_mask Nat (|> low_mask (i64.left_shifted 32))) @@ -57,12 +57,12 @@ (implementation: nat_codec (codec.Codec JSON Nat) - (def: (encode input) + (def: (encoded input) (let [high (|> input (i64.and high_mask) (i64.right_shifted 32)) low (i64.and low_mask input)] (#/.Array (row (|> high .int int.frac #/.Number) (|> low .int int.frac #/.Number))))) - (def: decode + (def: decoded (.result (.array (do <>.monad [high .number @@ -73,9 +73,10 @@ (implementation: int_codec (codec.Codec JSON Int) - (def: encode (|>> .nat (\ nat_codec encode))) - (def: decode - (|>> (\ nat_codec decode) (\ try.functor map .int)))) + (def: encoded + (|>> .nat (\ nat_codec encoded))) + (def: decoded + (|>> (\ nat_codec decoded) (\ try.functor map .int)))) (def: (nullable writer) {#.doc "Builds a JSON generator for potentially inexistent values."} @@ -89,33 +90,33 @@ (All [unit] (codec.Codec JSON (unit.Qty unit))) - (def: encode + (def: encoded (|>> ((debug.private unit.out)) - (\ ..int_codec encode))) - (def: decode - (|>> (\ ..int_codec decode) + (\ ..int_codec encoded))) + (def: decoded + (|>> (\ ..int_codec decoded) (\ try.functor map (debug.private unit.in))))) -(poly: encode +(poly: encoded (with_expansions [ (template [ ] [(do ! [.let [g!_ (code.local_identifier "_______")] _ ] - (in (` (: (~ (@JSON\encode inputT)) + (in (` (: (~ (@JSON\encoded inputT)) ))))] [(.exactly Any) (function ((~ g!_) (~ (code.identifier ["" "0"]))) #/.Null)] [(.sub Bit) (|>> #/.Boolean)] - [(.sub Nat) (\ (~! ..nat_codec) (~' encode))] - [(.sub Int) (\ (~! ..int_codec) (~' encode))] + [(.sub Nat) (\ (~! ..nat_codec) (~' encoded))] + [(.sub Int) (\ (~! ..int_codec) (~' encoded))] [(.sub Frac) (|>> #/.Number)] [(.sub Text) (|>> #/.String)])