diff options
author | Eduardo Julian | 2022-06-16 00:48:19 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-06-16 00:48:19 -0400 |
commit | 9e2f1e76f2c8df01ed7687d934c3210fcf676bd6 (patch) | |
tree | 115fab5bd8a5f53dc0d13ce5453095324a83496f /stdlib/source/polytypic | |
parent | f92c806ee8da63f04bbefbf558f6249bacdb47ea (diff) |
De-sigil-ification: suffix : [Part 13]
Diffstat (limited to 'stdlib/source/polytypic')
-rw-r--r-- | stdlib/source/polytypic/lux/abstract/equivalence.lux | 2 | ||||
-rw-r--r-- | stdlib/source/polytypic/lux/abstract/functor.lux | 4 | ||||
-rw-r--r-- | stdlib/source/polytypic/lux/data/format/json.lux | 38 |
3 files changed, 22 insertions, 22 deletions
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 [<basic> (with_template [<matcher> <encoder>] @@ -221,7 +221,7 @@ (<>.failure (format "Cannot create JSON encoder for: " (type.format inputT))) ))))) -(def: decoded +(def decoded (polytypic decoded (with_expansions [<basic> (with_template [<matcher> <decoder>] @@ -325,12 +325,12 @@ (<>.failure (format "Cannot create JSON decoder for: " (type.format inputT))) ))))) -(def: .public codec +(def .public codec (syntax (_ [inputT <code>.any]) (in (.list (` (is (codec.Codec /.JSON (~ inputT)) (implementation - (def: (~' encoded) + (def (~' encoded) ((~! ..encoded) (~ inputT))) - (def: (~' decoded) + (def (~' decoded) ((~! </>.result) ((~! ..decoded) (~ inputT)))) ))))))) |