From 4ca397765805eda5ddee393901ed3a02001a960a Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 25 Dec 2020 09:22:38 -0400 Subject: Replaced kebab-case with snake_case for naming convention. --- stdlib/source/poly/lux/abstract/equivalence.lux | 24 +++---- stdlib/source/poly/lux/abstract/functor.lux | 30 ++++----- stdlib/source/poly/lux/data/format/json.lux | 90 ++++++++++++------------- 3 files changed, 72 insertions(+), 72 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 f8d8d1fa8..b6cfa2c2c 100644 --- a/stdlib/source/poly/lux/abstract/equivalence.lux +++ b/stdlib/source/poly/lux/abstract/equivalence.lux @@ -43,12 +43,12 @@ (poly: #export equivalence (`` (do {! p.monad} - [#let [g!_ (code.local-identifier "_____________")] + [#let [g!_ (code.local_identifier "_____________")] *env* .env inputT .peek #let [@Equivalence (: (-> Type Code) (function (_ type) - (` ((~! /.Equivalence) (~ (poly.to-code *env* type))))))]] + (` ((~! /.Equivalence) (~ (poly.to_code *env* type))))))]] ($_ p.either ## Basic types (~~ (template [ ] @@ -109,9 +109,9 @@ (do ! [members (.variant (p.many equivalence)) #let [last (dec (list.size members)) - g!_ (code.local-identifier "_____________") - g!left (code.local-identifier "_____________left") - g!right (code.local-identifier "_____________right")]] + g!_ (code.local_identifier "_____________") + g!left (code.local_identifier "_____________left") + g!right (code.local_identifier "_____________right")]] (wrap (` (: (~ (@Equivalence inputT)) (function ((~ g!_) (~ g!left) (~ g!right)) (case [(~ g!left) (~ g!right)] @@ -129,10 +129,10 @@ ## Tuples (do ! [g!eqs (.tuple (p.many equivalence)) - #let [g!_ (code.local-identifier "_____________") + #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) @@ -141,11 +141,11 @@ ## Type recursion (do ! [[g!self bodyC] (.recursive equivalence) - #let [g!_ (code.local-identifier "_____________")]] + #let [g!_ (code.local_identifier "_____________")]] (wrap (` (: (~ (@Equivalence inputT)) ((~! /.rec) (.function ((~ g!_) (~ g!self)) (~ bodyC))))))) - .recursive-self + .recursive_self ## Type applications (do ! [[funcC argsC] (.apply (p.and equivalence (p.many equivalence)))] @@ -157,10 +157,10 @@ [[funcC varsC bodyC] (.polymorphic equivalence)] (wrap (` (: (All [(~+ varsC)] (-> (~+ (list\map (|>> (~) ((~! /.Equivalence)) (`)) varsC)) - ((~! /.Equivalence) ((~ (poly.to-code *env* inputT)) (~+ varsC))))) + ((~! /.Equivalence) ((~ (poly.to_code *env* inputT)) (~+ varsC))))) (function ((~ funcC) (~+ varsC)) (~ bodyC)))))) - .recursive-call + .recursive_call ## If all else fails... (|> .any (\ ! map (|>> %.type (format "Cannot create Equivalence for: ") p.fail)) diff --git a/stdlib/source/poly/lux/abstract/functor.lux b/stdlib/source/poly/lux/abstract/functor.lux index d640d4205..70f4f9b64 100644 --- a/stdlib/source/poly/lux/abstract/functor.lux +++ b/stdlib/source/poly/lux/abstract/functor.lux @@ -25,27 +25,27 @@ (poly: #export functor (do {! p.monad} - [#let [type-funcC (code.local-identifier "____________type-funcC") - funcC (code.local-identifier "____________funcC") - inputC (code.local-identifier "____________inputC")] + [#let [type_funcC (code.local_identifier "____________type_funcC") + funcC (code.local_identifier "____________funcC") + inputC (code.local_identifier "____________inputC")] *env* .env inputT .peek - [polyC varsC non-functorT] (.local (list inputT) + [polyC varsC non_functorT] (.local (list inputT) (.polymorphic .any)) - #let [num-vars (list.size varsC)] + #let [num_vars (list.size varsC)] #let [@Functor (: (-> Type Code) (function (_ unwrappedT) - (if (n.= 1 num-vars) - (` ((~! /.Functor) (~ (poly.to-code *env* unwrappedT)))) - (let [paramsC (|> num-vars dec list.indices (list\map (|>> %.nat code.local-identifier)))] + (if (n.= 1 num_vars) + (` ((~! /.Functor) (~ (poly.to_code *env* unwrappedT)))) + (let [paramsC (|> num_vars dec list.indices (list\map (|>> %.nat code.local_identifier)))] (` (All [(~+ paramsC)] - ((~! /.Functor) ((~ (poly.to-code *env* unwrappedT)) (~+ paramsC))))))))) + ((~! /.Functor) ((~ (poly.to_code *env* unwrappedT)) (~+ paramsC))))))))) Arg (: (-> Code (.Parser Code)) (function (Arg valueC) ($_ p.either ## Type-var (do p.monad - [#let [varI (|> num-vars (n.* 2) dec)] + [#let [varI (|> num_vars (n.* 2) dec)] _ (.parameter! varI)] (wrap (` ((~ funcC) (~ valueC))))) ## Variants @@ -67,7 +67,7 @@ (.tuple (loop [idx 0 pairsCC (: (List [Code Code]) (list))] - (p.either (let [slotC (|> idx %.nat (format "____________slot") code.local-identifier)] + (p.either (let [slotC (|> idx %.nat (format "____________slot") code.local_identifier)] (do ! [_ (wrap []) memberC (Arg slotC)] @@ -80,19 +80,19 @@ ## Functions (do ! [_ (wrap []) - #let [g! (code.local-identifier "____________") - outL (code.local-identifier "____________outL")] + #let [g! (code.local_identifier "____________") + outL (code.local_identifier "____________outL")] [inT+ outC] (.function (p.many .any) (Arg outL)) #let [inC+ (|> (list.size inT+) list.indices - (list\map (|>> %.nat (format "____________inC") code.local-identifier)))]] + (list\map (|>> %.nat (format "____________inC") code.local_identifier)))]] (wrap (` (function ((~ g!) (~+ inC+)) (let [(~ outL) ((~ valueC) (~+ inC+))] (~ outC)))))) ## Recursion (do p.monad - [_ .recursive-call] + [_ .recursive_call] (wrap (` ((~' map) (~ funcC) (~ valueC))))) ## Parameters (do p.monad diff --git a/stdlib/source/poly/lux/data/format/json.lux b/stdlib/source/poly/lux/data/format/json.lux index 3cba2eb3b..58784dccd 100644 --- a/stdlib/source/poly/lux/data/format/json.lux +++ b/stdlib/source/poly/lux/data/format/json.lux @@ -44,22 +44,22 @@ (-> Nat Frac) (|>> .int int.frac)) -(def: (rec-encode non-rec) +(def: (rec_encode non_rec) (All [a] (-> (-> (-> a JSON) (-> a JSON)) (-> a JSON))) (function (_ input) - (non-rec (rec-encode non-rec) input))) + (non_rec (rec_encode non_rec) input))) -(def: low-mask Nat (|> 1 (i64.left-shift 32) dec)) -(def: high-mask Nat (|> low-mask (i64.left-shift 32))) +(def: low_mask Nat (|> 1 (i64.left_shift 32) dec)) +(def: high_mask Nat (|> low_mask (i64.left_shift 32))) -(structure: nat-codec +(structure: nat_codec (codec.Codec JSON Nat) (def: (encode input) - (let [high (|> input (i64.and high-mask) (i64.logic-right-shift 32)) - low (i64.and low-mask input)] + (let [high (|> input (i64.and high_mask) (i64.logic_right_shift 32)) + low (i64.and low_mask input)] (#/.Array (row (|> high .int int.frac #/.Number) (|> low .int int.frac #/.Number))))) (def: decode @@ -67,15 +67,15 @@ (do <>.monad [high .number low .number] - (wrap (n.+ (|> high frac.int .nat (i64.left-shift 32)) + (wrap (n.+ (|> high frac.int .nat (i64.left_shift 32)) (|> low frac.int .nat)))))))) -(structure: int-codec +(structure: int_codec (codec.Codec JSON Int) - (def: encode (|>> .nat (\ nat-codec encode))) + (def: encode (|>> .nat (\ nat_codec encode))) (def: decode - (|>> (\ nat-codec decode) (\ try.functor map .int)))) + (|>> (\ nat_codec decode) (\ try.functor map .int)))) (def: (nullable writer) {#.doc "Builds a JSON generator for potentially inexistent values."} @@ -85,28 +85,28 @@ #.None #/.Null (#.Some value) (writer value)))) -(structure: qty-codec +(structure: qty_codec (All [unit] (codec.Codec JSON (unit.Qty unit))) (def: encode - (|>> unit.out (\ ..int-codec encode))) + (|>> unit.out (\ ..int_codec encode))) (def: decode - (|>> (\ ..int-codec decode) (\ try.functor map unit.in)))) + (|>> (\ ..int_codec decode) (\ try.functor map unit.in)))) (poly: encode - (with-expansions + (with_expansions [ (template [ ] [(do ! - [#let [g!_ (code.local-identifier "_______")] + [#let [g!_ (code.local_identifier "_______")] _ ] (wrap (` (: (~ (@JSON\encode 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) (~' encode))] + [(.sub Int) (\ (~! ..int_codec) (~' encode))] [(.sub Frac) (|>> #/.Number)] [(.sub Text) (|>> #/.String)])