From 9e2f1e76f2c8df01ed7687d934c3210fcf676bd6 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 16 Jun 2022 00:48:19 -0400 Subject: De-sigil-ification: suffix : [Part 13] --- .../source/polytypic/lux/abstract/equivalence.lux | 2 +- stdlib/source/polytypic/lux/abstract/functor.lux | 4 +-- stdlib/source/polytypic/lux/data/format/json.lux | 38 +++++++++++----------- 3 files changed, 22 insertions(+), 22 deletions(-) (limited to 'stdlib/source/polytypic') diff --git a/stdlib/source/polytypic/lux/abstract/equivalence.lux b/stdlib/source/polytypic/lux/abstract/equivalence.lux index 03d3dd3de..48accfa31 100644 --- a/stdlib/source/polytypic/lux/abstract/equivalence.lux +++ b/stdlib/source/polytypic/lux/abstract/equivalence.lux @@ -40,7 +40,7 @@ [\\library ["[0]" /]]) -(def: .public equivalence +(def .public equivalence (polytypic equivalence (`` (do [! <>.monad] [.let [g!_ (code.local "_____________")] diff --git a/stdlib/source/polytypic/lux/abstract/functor.lux b/stdlib/source/polytypic/lux/abstract/functor.lux index fc7cae722..07f2492cf 100644 --- a/stdlib/source/polytypic/lux/abstract/functor.lux +++ b/stdlib/source/polytypic/lux/abstract/functor.lux @@ -23,7 +23,7 @@ [\\library ["[0]" /]]) -(def: .public functor +(def .public functor (polytypic functor (do [! p.monad] [.let [g!_ (code.local "____________") @@ -107,5 +107,5 @@ (p.failure (format "Cannot create Functor for: " (%.type inputT)))))] (in (` (is (~ (@Functor inputT)) (implementation - (def: ((~' each) (~ funcC) (~ inputC)) + (def ((~' each) (~ funcC) (~ inputC)) (~ outputC))))))))) diff --git a/stdlib/source/polytypic/lux/data/format/json.lux b/stdlib/source/polytypic/lux/data/format/json.lux index 63017d5ba..972e074a5 100644 --- a/stdlib/source/polytypic/lux/data/format/json.lux +++ b/stdlib/source/polytypic/lux/data/format/json.lux @@ -38,29 +38,29 @@ [\\library ["[0]" / (.only JSON)]]) -(def: tag +(def tag (-> Nat Frac) (|>> .int int.frac)) -(def: (rec_encoded non_rec) +(def (rec_encoded non_rec) (All (_ a) (-> (-> (-> a JSON) (-> a JSON)) (-> a JSON))) (function (_ 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))) +(def low_mask Nat (|> 1 (i64.left_shifted 32) --)) +(def high_mask Nat (|> low_mask (i64.left_shifted 32))) -(def: nat_codec +(def nat_codec (codec.Codec JSON Nat) (implementation - (def: (encoded input) + (def (encoded input) (let [high (|> input (i64.and high_mask) (i64.right_shifted 32)) low (i64.and low_mask input)] {/.#Array (sequence (|> high .int int.frac {/.#Number}) (|> low .int int.frac {/.#Number}))})) - (def: decoded + (def decoded (.result (.array (do <>.monad [high .number @@ -68,34 +68,34 @@ (in (n.+ (|> high frac.int .nat (i64.left_shifted 32)) (|> low frac.int .nat))))))))) -(def: int_codec +(def int_codec (codec.Codec JSON Int) (implementation - (def: encoded + (def encoded (|>> .nat (at nat_codec encoded))) - (def: decoded + (def decoded (|>> (at nat_codec decoded) (at try.functor each (|>> .int)))))) ... Builds a JSON generator for potentially inexistent values. -(def: (nullable writer) +(def (nullable writer) (All (_ a) (-> (-> a JSON) (-> (Maybe a) JSON))) (function (_ elem) (case elem {.#None} {/.#Null} {.#Some value} (writer value)))) -(def: qty_codec +(def qty_codec (All (_ unit) (codec.Codec JSON (unit.Qty unit))) (implementation - (def: encoded + (def encoded (|>> unit.number (at ..int_codec encoded))) - (def: decoded + (def decoded (|>> (at ..int_codec decoded) (at try.functor each unit.quantity))))) -(def: encoded +(def encoded (polytypic encoded (with_expansions [ (with_template [ ] @@ -221,7 +221,7 @@ (<>.failure (format "Cannot create JSON encoder for: " (type.format inputT))) ))))) -(def: decoded +(def decoded (polytypic decoded (with_expansions [ (with_template [ ] @@ -325,12 +325,12 @@ (<>.failure (format "Cannot create JSON decoder for: " (type.format inputT))) ))))) -(def: .public codec +(def .public codec (syntax (_ [inputT .any]) (in (.list (` (is (codec.Codec /.JSON (~ inputT)) (implementation - (def: (~' encoded) + (def (~' encoded) ((~! ..encoded) (~ inputT))) - (def: (~' decoded) + (def (~' decoded) ((~! .result) ((~! ..decoded) (~ inputT)))) ))))))) -- cgit v1.2.3