From 4bc58162f3d381abf33c936eafc976a2f422258c Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 4 Jul 2018 21:34:07 -0400 Subject: - Re-named Bound to Paremeter. --- luxc/src/lux/analyser/base.clj | 2 +- luxc/src/lux/analyser/case.clj | 36 +++++++++++++++--------------- luxc/src/lux/analyser/lux.clj | 14 ++++++------ luxc/src/lux/analyser/proc/common.clj | 4 ++-- luxc/src/lux/analyser/proc/jvm.clj | 6 ++--- luxc/src/lux/base.clj | 2 +- luxc/src/lux/compiler/cache/type.clj | 6 ++--- luxc/src/lux/type.clj | 42 +++++++++++++++++------------------ luxc/src/lux/type/host.clj | 4 ++-- 9 files changed, 58 insertions(+), 58 deletions(-) (limited to 'luxc/src') diff --git a/luxc/src/lux/analyser/base.clj b/luxc/src/lux/analyser/base.clj index d0c856ffc..5339f8777 100644 --- a/luxc/src/lux/analyser/base.clj +++ b/luxc/src/lux/analyser/base.clj @@ -74,7 +74,7 @@ (return ?module))] (return (&/T [module* ?name])))) -(let [tag-names #{"Primitive" "Sum" "Product" "Function" "Bound" "Var" "Ex" "UnivQ" "ExQ" "Apply" "Named"}] +(let [tag-names #{"Primitive" "Sum" "Product" "Function" "Parameter" "Var" "Ex" "UnivQ" "ExQ" "Apply" "Named"}] (defn type-tag? [module name] (and (= "lux" module) (contains? tag-names name)))) diff --git a/luxc/src/lux/analyser/case.clj b/luxc/src/lux/analyser/case.clj index 2694c9447..d5a6e43cf 100644 --- a/luxc/src/lux/analyser/case.clj +++ b/luxc/src/lux/analyser/case.clj @@ -63,40 +63,40 @@ (|let [[_env _idx _var] frame] (&/T [_env (+ 2 _idx) _var]))) -(defn clean! [level ?tid bound-idx type] +(defn clean! [level ?tid parameter-idx type] (|case type (&/$Var ?id) (if (= ?tid ?id) - (&/$Bound (+ (* 2 level) bound-idx)) + (&/$Parameter (+ (* 2 level) parameter-idx)) type) (&/$Primitive ?name ?params) - (&/$Primitive ?name (&/|map (partial clean! level ?tid bound-idx) + (&/$Primitive ?name (&/|map (partial clean! level ?tid parameter-idx) ?params)) (&/$Function ?arg ?return) - (&/$Function (clean! level ?tid bound-idx ?arg) - (clean! level ?tid bound-idx ?return)) + (&/$Function (clean! level ?tid parameter-idx ?arg) + (clean! level ?tid parameter-idx ?return)) (&/$Apply ?param ?lambda) - (&/$Apply (clean! level ?tid bound-idx ?param) - (clean! level ?tid bound-idx ?lambda)) + (&/$Apply (clean! level ?tid parameter-idx ?param) + (clean! level ?tid parameter-idx ?lambda)) (&/$Product ?left ?right) - (&/$Product (clean! level ?tid bound-idx ?left) - (clean! level ?tid bound-idx ?right)) + (&/$Product (clean! level ?tid parameter-idx ?left) + (clean! level ?tid parameter-idx ?right)) (&/$Sum ?left ?right) - (&/$Sum (clean! level ?tid bound-idx ?left) - (clean! level ?tid bound-idx ?right)) + (&/$Sum (clean! level ?tid parameter-idx ?left) + (clean! level ?tid parameter-idx ?right)) (&/$UnivQ ?env ?body) - (&/$UnivQ (&/|map (partial clean! level ?tid bound-idx) ?env) - (clean! (inc level) ?tid bound-idx ?body)) + (&/$UnivQ (&/|map (partial clean! level ?tid parameter-idx) ?env) + (clean! (inc level) ?tid parameter-idx ?body)) (&/$ExQ ?env ?body) - (&/$ExQ (&/|map (partial clean! level ?tid bound-idx) ?env) - (clean! (inc level) ?tid bound-idx ?body)) + (&/$ExQ (&/|map (partial clean! level ?tid parameter-idx) ?env) + (clean! (inc level) ?tid parameter-idx ?body)) _ type @@ -139,10 +139,10 @@ (&/$Function (beta-reduce! level env ?input) (beta-reduce! level env ?output)) - (&/$Bound ?idx) + (&/$Parameter ?idx) (|case (&/|at (- ?idx (* 2 level)) env) - (&/$Some bound) - (beta-reduce! level env bound) + (&/$Some parameter) + (beta-reduce! level env parameter) _ type) diff --git a/luxc/src/lux/analyser/lux.clj b/luxc/src/lux/analyser/lux.clj index 781f9854b..35ac72e93 100644 --- a/luxc/src/lux/analyser/lux.clj +++ b/luxc/src/lux/analyser/lux.clj @@ -16,7 +16,7 @@ [meta :as &&meta]))) ;; [Utils] -;; TODO: Walk the type to set up the bound-type, instead of doing a +;; TODO: Walk the type to set up the parameter-type, instead of doing a ;; rough calculation like this one. (defn ^:private count-univq [type] "(-> Type Int)" @@ -29,9 +29,9 @@ ;; TODO: This technique will not work if the body of the type contains ;; nested quantifications that cannot be directly counted. -(defn ^:private next-bound-type [type] +(defn ^:private next-parameter-type [type] "(-> Type Type)" - (&/$Bound (->> (count-univq type) (* 2) (+ 1)))) + (&/$Parameter (->> (count-univq type) (* 2) (+ 1)))) (defn ^:private embed-inferred-input [input output] "(-> Type Type Type)" @@ -75,7 +75,7 @@ =var (&type/resolve-type $var) inferred-type (|case =var (&/$Var iid) - (|do [:let [=var* (next-bound-type tuple-type)] + (|do [:let [=var* (next-parameter-type tuple-type)] _ (&type/set-var iid =var*) tuple-type* (&type/clean $var tuple-type)] (return (&/$UnivQ &/$Nil tuple-type*))) @@ -184,7 +184,7 @@ =var (&type/resolve-type $var) inferred-type (|case =var (&/$Var iid) - (|do [:let [=var* (next-bound-type variant-type)] + (|do [:let [=var* (next-parameter-type variant-type)] _ (&type/set-var iid =var*) variant-type* (&type/clean $var variant-type)] (return (&/$UnivQ &/$Nil variant-type*))) @@ -328,7 +328,7 @@ (|do [? (&type/bound? ?id) type** (if ? (&type/clean $var =output-t) - (|do [_ (&type/set-var ?id (next-bound-type =output-t)) + (|do [_ (&type/set-var ?id (next-parameter-type =output-t)) cleaned-output* (&type/clean $var =output-t) :let [cleaned-output (&/$UnivQ &/$Nil cleaned-output*)]] (return cleaned-output))) @@ -431,7 +431,7 @@ (defn ^:private clean-func-inference [$input $output =input =func] (|case =input (&/$Var iid) - (|do [:let [=input* (next-bound-type =func)] + (|do [:let [=input* (next-parameter-type =func)] _ (&type/set-var iid =input*) =func* (&type/clean $input =func) =func** (&type/clean $output =func*)] diff --git a/luxc/src/lux/analyser/proc/common.clj b/luxc/src/lux/analyser/proc/common.clj index 0d7b6dd1e..243308799 100644 --- a/luxc/src/lux/analyser/proc/common.clj +++ b/luxc/src/lux/analyser/proc/common.clj @@ -260,7 +260,7 @@ (defn ^:private analyse-array-new [analyse exo-type ?values] (|do [:let [(&/$Cons length (&/$Nil)) ?values] =length (&&/analyse-1 analyse &type/Nat length) - _ (&type/check exo-type (&/$UnivQ (&/|list) (&type/Array (&/$Bound 1)))) + _ (&type/check exo-type (&/$UnivQ (&/|list) (&type/Array (&/$Parameter 1)))) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["array" "new"]) (&/|list =length) (&/|list))))))) @@ -382,7 +382,7 @@ (fn [$var] (|do [:let [(&/$Cons ?init (&/$Nil)) ?values] =init (&&/analyse-1 analyse $var ?init) - _ (&type/check exo-type (&/$UnivQ (&/|list) (&type/Box (&/$Bound 1) $var))) + _ (&type/check exo-type (&/$UnivQ (&/|list) (&type/Box (&/$Parameter 1) $var))) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["box" "new"]) (&/|list =init) (&/|list))))))))) diff --git a/luxc/src/lux/analyser/proc/jvm.clj b/luxc/src/lux/analyser/proc/jvm.clj index 8ad13c74b..b6d291073 100644 --- a/luxc/src/lux/analyser/proc/jvm.clj +++ b/luxc/src/lux/analyser/proc/jvm.clj @@ -84,7 +84,7 @@ (if ? (|do [real-type (&type/deref id)] (return (&/T [idx real-type]))) - (return (&/T [(+ 2 idx) (&/$Bound idx)])))))) + (return (&/T [(+ 2 idx) (&/$Parameter idx)])))))) (defn ^:private clean-gtype-vars [gtype-vars] (|do [[_ clean-types] (&/fold% (fn [idx+types gtype-var] @@ -99,7 +99,7 @@ "(-> Text (List Type) Type)" (&/fold (fn [base-type type-arg] (|case type-arg - (&/$Bound _) + (&/$Parameter _) (&/$UnivQ &type/empty-env base-type) _ @@ -204,7 +204,7 @@ (return (&/$Primitive &host-type/array-data-tag (&/|list =param)))) (&/$GenericWildcard _) - (return (&/$ExQ &/$Nil (&/$Bound 1))) + (return (&/$ExQ &/$Nil (&/$Parameter 1))) )) (defn gen-super-env [class-env supers class-decl] diff --git a/luxc/src/lux/base.clj b/luxc/src/lux/base.clj index e1f48d23b..1010bf418 100644 --- a/luxc/src/lux/base.clj +++ b/luxc/src/lux/base.clj @@ -89,7 +89,7 @@ ("Sum" 2) ("Product" 2) ("Function" 2) - ("Bound" 1) + ("Parameter" 1) ("Var" 1) ("Ex" 1) ("UnivQ" 2) diff --git a/luxc/src/lux/compiler/cache/type.clj b/luxc/src/lux/compiler/cache/type.clj index 338673807..bf5e04ec6 100644 --- a/luxc/src/lux/compiler/cache/type.clj +++ b/luxc/src/lux/compiler/cache/type.clj @@ -41,7 +41,7 @@ (&/$ExQ env body) (str "E" (serialize-list serialize-type env) (serialize-type body)) - (&/$Bound idx) + (&/$Parameter idx) (str "$" idx stop) (&/$Ex idx) @@ -96,7 +96,7 @@ (let [[idx ^String input*] (.split (.substring input 1) stop 2)] [( (Long/parseLong idx)) input*]))) - ^:private deserialize-bound "$" &/$Bound + ^:private deserialize-parameter "$" &/$Parameter ^:private deserialize-ex "!" &/$Ex ^:private deserialize-var "?" &/$Var ) @@ -133,7 +133,7 @@ (deserialize-prod input) (deserialize-lambda input) (deserialize-app input) - (deserialize-bound input) + (deserialize-parameter input) (deserialize-ex input) (deserialize-var input) (deserialize-named input) diff --git a/luxc/src/lux/type.clj b/luxc/src/lux/type.clj index 3a7b7cc9b..173f144b9 100644 --- a/luxc/src/lux/type.clj +++ b/luxc/src/lux/type.clj @@ -25,7 +25,7 @@ (def I64 (&/$Named (&/T ["lux" "I64"]) (&/$UnivQ empty-env - (&/$Primitive "#I64" (&/|list (&/$Bound 1)))))) + (&/$Primitive "#I64" (&/|list (&/$Parameter 1)))))) (def Nat* (&/$Primitive &&host/nat-data-tag &/$Nil)) (def Deg* (&/$Primitive &&host/deg-data-tag &/$Nil)) (def Int* (&/$Primitive &&host/int-data-tag &/$Nil)) @@ -56,17 +56,17 @@ (def Nothing (&/$Named (&/T ["lux" "Nothing"]) (&/$UnivQ empty-env - (&/$Bound 1)))) + (&/$Parameter 1)))) (def Any (&/$Named (&/T ["lux" "Any"]) (&/$ExQ empty-env - (&/$Bound 1)))) + (&/$Parameter 1)))) (def IO (&/$Named (&/T ["lux/codata" "IO"]) (&/$UnivQ empty-env - (&/$Function Nothing (&/$Bound 1))))) + (&/$Function Nothing (&/$Parameter 1))))) (def List (&/$Named (&/T ["lux" "List"]) @@ -75,9 +75,9 @@ ;; lux;Nil Any ;; lux;Cons - (&/$Product (&/$Bound 1) - (&/$Apply (&/$Bound 1) - (&/$Bound 0))))))) + (&/$Product (&/$Parameter 1) + (&/$Apply (&/$Parameter 1) + (&/$Parameter 0))))))) (def Maybe (&/$Named (&/T ["lux" "Maybe"]) @@ -86,12 +86,12 @@ ;; lux;None Any ;; lux;Some - (&/$Bound 1)) + (&/$Parameter 1)) ))) (def Type (&/$Named (&/T ["lux" "Type"]) - (let [Type (&/$Apply (&/$Bound 1) (&/$Bound 0)) + (let [Type (&/$Apply (&/$Parameter 1) (&/$Parameter 0)) TypeList (&/$Apply Type List) TypePair (&/$Product Type Type)] (&/$Apply Nothing @@ -109,7 +109,7 @@ ;; Function TypePair (&/$Sum - ;; Bound + ;; Parameter Nat (&/$Sum ;; Var @@ -138,14 +138,14 @@ (&/$Named (&/T ["lux" "Meta"]) (&/$UnivQ empty-env (&/$UnivQ empty-env - (&/$Product (&/$Bound 3) - (&/$Bound 1)))))) + (&/$Product (&/$Parameter 3) + (&/$Parameter 1)))))) (def Code* (&/$Named (&/T ["lux" "Code'"]) - (let [Code (&/$Apply (&/$Apply (&/$Bound 1) - (&/$Bound 0)) - (&/$Bound 1)) + (let [Code (&/$Apply (&/$Apply (&/$Parameter 1) + (&/$Parameter 0)) + (&/$Parameter 1)) Code-List (&/$Apply Code List)] (&/$UnivQ empty-env (&/$Sum ;; "lux;Bool" @@ -204,7 +204,7 @@ (return* state type) (&/$None) - ((&/fail-with-loc (str "[Type Error] Unbound type-var: " id)) + ((&/fail-with-loc (str "[Type Error] Un-bound type-var: " id)) state)) ((&/fail-with-loc (str "[Type Error] Unknown type-var: " id)) state)))) @@ -454,7 +454,7 @@ (&/$Ex ?id) (str "⟨e:" ?id "⟩") - (&/$Bound idx) + (&/$Parameter idx) (str idx) (&/$Apply _ _) @@ -502,7 +502,7 @@ [(&/$Var xid) (&/$Var yid)] (= xid yid) - [(&/$Bound xidx) (&/$Bound yidx)] + [(&/$Parameter xidx) (&/$Parameter yidx)] (= xidx yidx) [(&/$Ex xid) (&/$Ex yid)] @@ -597,10 +597,10 @@ (&/$Function ?input ?output) (&/$Function (beta-reduce env ?input) (beta-reduce env ?output)) - (&/$Bound ?idx) + (&/$Parameter ?idx) (|case (&/|at ?idx env) - (&/$Some bound) - (beta-reduce env bound) + (&/$Some parameter) + (beta-reduce env parameter) _ (assert false (str "[Type Error] Unknown var: " ?idx " | " (&/->seq (&/|map show-type env))))) diff --git a/luxc/src/lux/type/host.clj b/luxc/src/lux/type/host.clj index bb7459c48..bdf0d7b50 100644 --- a/luxc/src/lux/type/host.clj +++ b/luxc/src/lux/type/host.clj @@ -35,7 +35,7 @@ [(&/$Var xid) (&/$Var yid)] (= xid yid) - [(&/$Bound xidx) (&/$Bound yidx)] + [(&/$Parameter xidx) (&/$Parameter yidx)] (= xidx yidx) [(&/$Ex xid) (&/$Ex yid)] @@ -61,7 +61,7 @@ (def ^:private Any (&/$Named (&/T ["lux" "Any"]) (&/$ExQ (&/|list) - (&/$Bound 1)))) + (&/$Parameter 1)))) ;; [Exports] (def array-data-tag "#Array") -- cgit v1.2.3