diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux.lux | 10 | ||||
-rw-r--r-- | stdlib/source/lux/concurrency/stm.lux | 16 | ||||
-rw-r--r-- | stdlib/source/lux/data/bit.lux | 8 | ||||
-rw-r--r-- | stdlib/source/lux/data/number.lux | 32 | ||||
-rw-r--r-- | stdlib/source/lux/data/text.lux | 2 | ||||
-rw-r--r-- | stdlib/source/lux/host.js.lux | 16 | ||||
-rw-r--r-- | stdlib/source/lux/host.jvm.lux | 4 | ||||
-rw-r--r-- | stdlib/source/lux/io.lux | 8 | ||||
-rw-r--r-- | stdlib/source/lux/lang/compiler/analysis/case.lux | 4 | ||||
-rw-r--r-- | stdlib/source/lux/lang/compiler/extension/analysis/common.lux | 4 | ||||
-rw-r--r-- | stdlib/source/lux/lang/compiler/extension/analysis/host.jvm.lux | 22 | ||||
-rw-r--r-- | stdlib/source/lux/lang/compiler/synthesis/case.lux | 2 | ||||
-rw-r--r-- | stdlib/source/lux/lang/compiler/translation/scheme/case.jvm.lux | 2 | ||||
-rw-r--r-- | stdlib/source/lux/macro.lux | 4 | ||||
-rw-r--r-- | stdlib/source/lux/world/blob.jvm.lux | 4 | ||||
-rw-r--r-- | stdlib/source/lux/world/console.lux | 2 |
16 files changed, 70 insertions, 70 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index 72e22a485..55499d6cc 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -2859,16 +2859,16 @@ _ (fail "Wrong syntax for :")})) -(macro:' #export (:! tokens) +(macro:' #export (:coerce tokens) (list [(tag$ ["lux" "doc"]) (text$ "## The type-coercion macro. - (:! Dinosaur (list 1 2 3))")]) + (:coerce Dinosaur (list 1 2 3))")]) ("lux case" tokens {(#Cons type (#Cons value #Nil)) (return (list (` ("lux coerce" (type (~ type)) (~ value))))) _ - (fail "Wrong syntax for :!")})) + (fail "Wrong syntax for :coerce")})) (def:''' (empty? xs) #Nil @@ -5329,7 +5329,7 @@ (do-template [<name> <to>] [(def: #export <name> (-> (I64 Any) <to>) - (|>> (:! <to>)))] + (|>> (:coerce <to>)))] [i64 I64] [nat Nat] @@ -5700,7 +5700,7 @@ (case (flatten-alias type) (^template [<name> <type> <wrapper>] (#Named ["lux" <name>] _) - (wrap (<wrapper> (:! <type> value)))) + (wrap (<wrapper> (:coerce <type> value)))) (["Bool" Bool bool$] ["Nat" Nat nat$] ["Int" Int int$] diff --git a/stdlib/source/lux/concurrency/stm.lux b/stdlib/source/lux/concurrency/stm.lux index 791419444..5c9e2d68c 100644 --- a/stdlib/source/lux/concurrency/stm.lux +++ b/stdlib/source/lux/concurrency/stm.lux @@ -76,8 +76,8 @@ (All [a] (-> (Var a) Tx (Maybe a))) (|> tx (list.find (function (_ [_var _original _current]) - (is? (:! (Var Any) var) - (:! (Var Any) _var)))) + (is? (:coerce (Var Any) var) + (:coerce (Var Any) _var)))) (:: maybe.Monad<Maybe> map (function (_ [_var _original _current]) _current)) (:assume) @@ -102,11 +102,11 @@ #.Nil (#.Cons [_var _original _current] tx') - (if (is? (:! (Var Any) var) - (:! (Var Any) _var)) - (#.Cons {#var (:! (Var Any) _var) - #original (:! Any _original) - #current (:! Any value)} + (if (is? (:coerce (Var Any) var) + (:coerce (Var Any) _var)) + (#.Cons {#var (:coerce (Var Any) _var) + #original (:coerce Any _original) + #current (:coerce Any value)} tx') (#.Cons {#var _var #original _original @@ -220,7 +220,7 @@ (if was-first? (exec (|> (io.run (atom.read pending-commits)) (promise.await (function (recur [head tail]) - (io (exec (process-commit (:! [(STM Any) (Promise Any)] head)) + (io (exec (process-commit (:coerce [(STM Any) (Promise Any)] head)) (promise.await recur tail)))))) (wrap [])) (wrap []))) diff --git a/stdlib/source/lux/data/bit.lux b/stdlib/source/lux/data/bit.lux index a0f8e18a7..22ac6522a 100644 --- a/stdlib/source/lux/data/bit.lux +++ b/stdlib/source/lux/data/bit.lux @@ -47,11 +47,11 @@ (def: #export not {#.doc "Bitwise negation."} (All [s] (-> (I64 s) (I64 s))) - (xor (:! I64 -1))) + (xor (:coerce I64 -1))) (def: (flag idx) (-> Nat I64) - (|> +1 (:! I64) (left-shift idx))) + (|> +1 (:coerce I64) (left-shift idx))) (def: #export (clear idx input) {#.doc "Clear bit at given index."} @@ -70,7 +70,7 @@ (def: #export (set? idx input) (-> Nat (I64 Any) Bool) - (|> input (:! I64) (..and (flag idx)) (n/= +0) .not)) + (|> input (:coerce I64) (..and (flag idx)) (n/= +0) .not)) (do-template [<name> <main> <comp>] [(def: #export (<name> distance input) @@ -86,4 +86,4 @@ (def: #export (region size offset) (-> Nat Nat I64) - (|> +1 (:! I64) (left-shift size) dec (left-shift offset))) + (|> +1 (:coerce I64) (left-shift size) dec (left-shift offset))) diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux index 640bff8a2..df685c150 100644 --- a/stdlib/source/lux/data/number.lux +++ b/stdlib/source/lux/data/number.lux @@ -80,10 +80,10 @@ (def: * d/*) (def: / d//) (def: % d/%) - (def: (negate x) (d/- x (:! Deg -1))) + (def: (negate x) (d/- x (:coerce Deg -1))) (def: abs id) (def: (signum x) - (:! Deg -1))) + (:coerce Deg -1))) (do-template [<type> <order> <succ> <pred>] [(struct: #export _ (Enum <type>) @@ -103,10 +103,10 @@ (def: top <top>) (def: bottom <bottom>))] - [ Nat Enum<Nat> (:! Nat -1) +0] + [ Nat Enum<Nat> (:coerce Nat -1) +0] [ Int Enum<Int> 9_223_372_036_854_775_807 -9_223_372_036_854_775_808] [Frac Enum<Frac> ("lux frac max") ("lux frac min")] - [ Deg Enum<Deg> (:! Deg -1) (:! Deg +0)] + [ Deg Enum<Deg> (:coerce Deg -1) (:coerce Deg +0)] ) (do-template [<name> <type> <identity> <compose>] @@ -364,7 +364,7 @@ (#.Some digit-value) (recur (inc idx) - (|> output (i/* <base>) (i/+ (:! Int digit-value)))))) + (|> output (i/* <base>) (i/+ (:coerce Int digit-value)))))) (#e.Success (i/* sign output))))) (#e.Error <error>)))))] @@ -381,7 +381,7 @@ (do-template [<struct> <nat> <char-bit-size> <error>] [(struct: #export <struct> (Codec Text Deg) (def: (encode value) - (let [raw-output (de-prefix (:: <nat> encode (:! Nat value))) + (let [raw-output (de-prefix (:: <nat> encode (:coerce Nat value))) max-num-chars (n// <char-bit-size> +64) raw-size ("lux text size" raw-output) zero-padding (loop [zeroes-left (n/- raw-size max-num-chars) @@ -400,7 +400,7 @@ (^multi (^ (#.Some (char "."))) [(:: <nat> decode ("lux text concat" "+" (de-prefix repr))) (#e.Success output)]) - (#e.Success (:! Deg output)) + (#e.Success (:coerce Deg output)) _ (#e.Error ("lux text concat" <error> repr))) @@ -751,7 +751,7 @@ (loop [idx idx carry +0 output output] - (if (i/>= 0 (:! Int idx)) + (if (i/>= 0 (:coerce Int idx)) (let [raw (|> (digits-get idx output) (n/* +5) (n/+ carry))] @@ -765,7 +765,7 @@ (loop [times power output (|> (make-digits []) (digits-put power +1))] - (if (i/>= 0 (:! Int times)) + (if (i/>= 0 (:coerce Int times)) (recur (dec times) (digits-times-5! power output)) output))) @@ -775,7 +775,7 @@ (loop [idx (dec bit.width) all-zeroes? true output ""] - (if (i/>= 0 (:! Int idx)) + (if (i/>= 0 (:coerce Int idx)) (let [digit (digits-get idx digits)] (if (and (n/= +0 digit) all-zeroes?) @@ -783,7 +783,7 @@ (recur (dec idx) false ("lux text concat" - (:: Codec<Text,Int> encode (:! Int digit)) + (:: Codec<Text,Int> encode (:coerce Int digit)) output)))) (if all-zeroes? "0" @@ -794,7 +794,7 @@ (loop [idx (dec bit.width) carry +0 output (make-digits [])] - (if (i/>= 0 (:! Int idx)) + (if (i/>= 0 (:coerce Int idx)) (let [raw ($_ n/+ carry (digits-get idx param) @@ -855,13 +855,13 @@ (struct: #export _ (Codec Text Deg) (def: (encode input) - (let [input (:! Nat input) + (let [input (:coerce Nat input) last-idx (dec bit.width)] (if (n/= +0 input) ".0" (loop [idx last-idx digits (make-digits [])] - (if (i/>= 0 (:! Int idx)) + (if (i/>= 0 (:coerce Int idx)) (if (bit.set? idx input) (let [digits' (digits-add (digits-power (n/- idx last-idx)) digits)] @@ -897,7 +897,7 @@ (recur (digits-sub! power digits) (inc idx) (bit.set (n/- idx (dec bit.width)) output)))) - (#e.Success (:! Deg output)))) + (#e.Success (:coerce Deg output)))) #.None (#e.Error ("lux text concat" "Wrong syntax for Deg: " input))) @@ -1009,4 +1009,4 @@ (struct: #export _ (Hash Deg) (def: eq Eq<Deg>) - (def: hash (|>> (:! Nat)))) + (def: hash (|>> (:coerce Nat)))) diff --git a/stdlib/source/lux/data/text.lux b/stdlib/source/lux/data/text.lux index 6d11bb9b0..58826e2c9 100644 --- a/stdlib/source/lux/data/text.lux +++ b/stdlib/source/lux/data/text.lux @@ -209,7 +209,7 @@ (def: #export from-code (-> Nat Text) - (|>> (:! Int) "lux int char")) + (|>> (:coerce Int) "lux int char")) (def: #export (space? char) {#.doc "Checks whether the character is white-space."} diff --git a/stdlib/source/lux/host.js.lux b/stdlib/source/lux/host.js.lux index 7ad985f1a..876ab0c38 100644 --- a/stdlib/source/lux/host.js.lux +++ b/stdlib/source/lux/host.js.lux @@ -40,8 +40,8 @@ {#.doc (doc "A way to get fields from objects." (get "ceil" (ref "Math")) (get "ceil" (-> Frac Frac) (ref "Math")))} - (wrap (list (` (:! (~ type) - ("js get-field" (~ object) (~ field-name))))))) + (wrap (list (` (:coerce (~ type) + ("js get-field" (~ object) (~ field-name))))))) (syntax: #export (object {kvs (p.some (p.seq s.any s.any))}) {#.doc (doc "A way to create JavaScript objects." @@ -57,8 +57,8 @@ {#.doc (doc "A way to refer to JavaScript variables." (ref "document") (ref "Math.ceil" (-> Frac Frac)))} - (wrap (list (` (:! (~ (default (' ..Object) type)) - ("js ref" (~ (code.text name)))))))) + (wrap (list (` (:coerce (~ (default (' ..Object) type)) + ("js ref" (~ (code.text name)))))))) (do-template [<name> <proc> <doc>] [(syntax: #export (<name>) @@ -77,9 +77,9 @@ (call! (ref "Math") "ceil" [123.45]))} (case shape (#.Left [function args ?type]) - (wrap (list (` (:! (~ (default (' ..Object) ?type)) - ("js call" (~ function) (~+ args)))))) + (wrap (list (` (:coerce (~ (default (' ..Object) ?type)) + ("js call" (~ function) (~+ args)))))) (#.Right [object field args ?type]) - (wrap (list (` (:! (~ (default (' ..Object) ?type)) - ("js object-call" (~ object) (~ (code.text field)) (~+ args)))))))) + (wrap (list (` (:coerce (~ (default (' ..Object) ?type)) + ("js object-call" (~ object) (~ (code.text field)) (~+ args)))))))) diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux index 5fbeae68d..ae4b78aac 100644 --- a/stdlib/source/lux/host.jvm.lux +++ b/stdlib/source/lux/host.jvm.lux @@ -1561,8 +1561,8 @@ [return-type (let [g!temp (code.symbol ["" " Ω "])] (` (let [(~ g!temp) (~ return-term)] - (if (not (null? (:! (primitive "java.lang.Object") - (~ g!temp)))) + (if (not (null? (:coerce (primitive "java.lang.Object") + (~ g!temp)))) (~ g!temp) (error! "Cannot produce null references from method calls.")))))]) diff --git a/stdlib/source/lux/io.lux b/stdlib/source/lux/io.lux index 21d70de61..a50c501d1 100644 --- a/stdlib/source/lux/io.lux +++ b/stdlib/source/lux/io.lux @@ -27,13 +27,13 @@ (struct: #export _ (Functor IO) (def: (map f ma) - (io (f (ma (:! Nothing [])))))) + (io (f (ma (:coerce Nothing [])))))) (struct: #export _ (Apply IO) (def: functor Functor<IO>) (def: (apply ff fa) - (io ((ff (:! Nothing [])) (fa (:! Nothing [])))))) + (io ((ff (:coerce Nothing [])) (fa (:coerce Nothing [])))))) (struct: #export _ (Monad IO) (def: functor Functor<IO>) @@ -42,12 +42,12 @@ (io x)) (def: (join mma) - (io ((mma (:! Nothing [])) (:! Nothing []))))) + (io ((mma (:coerce Nothing [])) (:coerce Nothing []))))) (def: #export (run action) {#.doc "A way to execute IO computations and perform their side-effects."} (All [a] (-> (IO a) a)) - (action (:! Nothing []))) + (action (:coerce Nothing []))) (def: #export (exit code) (-> Int (IO Nothing)) diff --git a/stdlib/source/lux/lang/compiler/analysis/case.lux b/stdlib/source/lux/lang/compiler/analysis/case.lux index 9e67a24f9..84eb23af5 100644 --- a/stdlib/source/lux/lang/compiler/analysis/case.lux +++ b/stdlib/source/lux/lang/compiler/analysis/case.lux @@ -194,8 +194,8 @@ (Operation [(List Pattern) a]))) (function (_ [memberT memberC] then) (do @ - [[memberP [memberP+ thenA]] ((:! (All [a] (-> (Maybe Nat) Type Code (Operation a) (Operation [Pattern a]))) - analyse-pattern) + [[memberP [memberP+ thenA]] ((:coerce (All [a] (-> (Maybe Nat) Type Code (Operation a) (Operation [Pattern a]))) + analyse-pattern) #.None memberT memberC then)] (wrap [(list& memberP memberP+) thenA])))) (do @ diff --git a/stdlib/source/lux/lang/compiler/extension/analysis/common.lux b/stdlib/source/lux/lang/compiler/extension/analysis/common.lux index 6bd1a93bf..ca1c51df9 100644 --- a/stdlib/source/lux/lang/compiler/extension/analysis/common.lux +++ b/stdlib/source/lux/lang/compiler/extension/analysis/common.lux @@ -102,14 +102,14 @@ ## (^ (list typeC valueC)) ## (do compiler.Monad<Operation> ## [actualT (eval Type typeC) -## _ (typeA.infer (:! Type actualT))] +## _ (typeA.infer (:coerce Type actualT))] ## (typeA.with-type <type> ## (analyse valueC))) ## _ ## (lang.throw ///bundle.incorrect-arity [extension +2 (list.size args)]))))] -## [lux//check (:! Type actualT)] +## [lux//check (:coerce Type actualT)] ## [lux//coerce Any] ## ) diff --git a/stdlib/source/lux/lang/compiler/extension/analysis/host.jvm.lux b/stdlib/source/lux/lang/compiler/extension/analysis/host.jvm.lux index 56da166c5..1fb9d8d90 100644 --- a/stdlib/source/lux/lang/compiler/extension/analysis/host.jvm.lux +++ b/stdlib/source/lux/lang/compiler/extension/analysis/host.jvm.lux @@ -545,10 +545,10 @@ (def: (java-type-to-class type) (-> java/lang/reflect/Type (Meta Text)) (cond (host.instance? Class type) - (macro/wrap (Class::getName [] (:! Class type))) + (macro/wrap (Class::getName [] (:coerce Class type))) (host.instance? ParameterizedType type) - (java-type-to-class (ParameterizedType::getRawType [] (:! ParameterizedType type))) + (java-type-to-class (ParameterizedType::getRawType [] (:coerce ParameterizedType type))) ## else (lang.throw Cannot-Convert-To-Class (jvm-type-name type)))) @@ -561,7 +561,7 @@ (def: (java-type-to-lux-type mappings java-type) (-> Mappings java/lang/reflect/Type (Meta Type)) (cond (host.instance? TypeVariable java-type) - (let [var-name (TypeVariable::getName [] (:! TypeVariable java-type))] + (let [var-name (TypeVariable::getName [] (:coerce TypeVariable java-type))] (case (dict.get var-name mappings) (#.Some var-type) (macro/wrap var-type) @@ -570,7 +570,7 @@ (lang.throw Unknown-Type-Var var-name))) (host.instance? WildcardType java-type) - (let [java-type (:! WildcardType java-type)] + (let [java-type (:coerce WildcardType java-type)] (case [(array.read +0 (WildcardType::getUpperBounds [] java-type)) (array.read +0 (WildcardType::getLowerBounds [] java-type))] (^or [(#.Some bound) _] [_ (#.Some bound)]) @@ -580,7 +580,7 @@ (macro/wrap Any))) (host.instance? Class java-type) - (let [java-type (:! (Class Object) java-type) + (let [java-type (:coerce (Class Object) java-type) class-name (Class::getName [] java-type)] (macro/wrap (case (array.size (Class::getTypeParameters [] java-type)) +0 @@ -594,7 +594,7 @@ (type.univ-q arity))))) (host.instance? ParameterizedType java-type) - (let [java-type (:! ParameterizedType java-type) + (let [java-type (:coerce ParameterizedType java-type) raw (ParameterizedType::getRawType [] java-type)] (if (host.instance? Class raw) (do macro.Monad<Meta> @@ -602,13 +602,13 @@ (ParameterizedType::getActualTypeArguments []) array.to-list (monad.map @ (java-type-to-lux-type mappings)))] - (macro/wrap (#.Primitive (Class::getName [] (:! (Class Object) raw)) + (macro/wrap (#.Primitive (Class::getName [] (:coerce (Class Object) raw)) paramsT))) (lang.throw jvm-type-is-not-a-class raw))) (host.instance? GenericArrayType java-type) (do macro.Monad<Meta> - [innerT (|> (:! GenericArrayType java-type) + [innerT (|> (:coerce GenericArrayType java-type) (GenericArrayType::getGenericComponentType []) (java-type-to-lux-type mappings))] (wrap (#.Primitive "#Array" (list innerT)))) @@ -884,10 +884,10 @@ (def: (java-type-to-parameter type) (-> java/lang/reflect/Type (Meta Text)) (cond (host.instance? Class type) - (macro/wrap (Class::getName [] (:! Class type))) + (macro/wrap (Class::getName [] (:coerce Class type))) (host.instance? ParameterizedType type) - (java-type-to-parameter (ParameterizedType::getRawType [] (:! ParameterizedType type))) + (java-type-to-parameter (ParameterizedType::getRawType [] (:coerce ParameterizedType type))) (or (host.instance? TypeVariable type) (host.instance? WildcardType type)) @@ -895,7 +895,7 @@ (host.instance? GenericArrayType type) (do macro.Monad<Meta> - [componentP (java-type-to-parameter (GenericArrayType::getGenericComponentType [] (:! GenericArrayType type)))] + [componentP (java-type-to-parameter (GenericArrayType::getGenericComponentType [] (:coerce GenericArrayType type)))] (wrap (format componentP "[]"))) ## else diff --git a/stdlib/source/lux/lang/compiler/synthesis/case.lux b/stdlib/source/lux/lang/compiler/synthesis/case.lux index b7f224168..c12930963 100644 --- a/stdlib/source/lux/lang/compiler/synthesis/case.lux +++ b/stdlib/source/lux/lang/compiler/synthesis/case.lux @@ -99,7 +99,7 @@ rightP <default>)) ([#//.Bool bool/=] - [#//.I64 (:! (Eq I64) i/=)] + [#//.I64 (:coerce (Eq I64) i/=)] [#//.F64 frac/=] [#//.Text text/=]) diff --git a/stdlib/source/lux/lang/compiler/translation/scheme/case.jvm.lux b/stdlib/source/lux/lang/compiler/translation/scheme/case.jvm.lux index e5d12a005..40d2625fb 100644 --- a/stdlib/source/lux/lang/compiler/translation/scheme/case.jvm.lux +++ b/stdlib/source/lux/lang/compiler/translation/scheme/case.jvm.lux @@ -32,7 +32,7 @@ (.let [method (.if tail? //runtime.product//right //runtime.product//left)] - (method source (_.int (:! Int idx))))) + (method source (_.int (:coerce Int idx))))) valueO pathP)))) diff --git a/stdlib/source/lux/macro.lux b/stdlib/source/lux/macro.lux index 91a83864c..982dec71b 100644 --- a/stdlib/source/lux/macro.lux +++ b/stdlib/source/lux/macro.lux @@ -251,7 +251,7 @@ [def-type def-anns def-value] (: (Maybe Definition) (|> (: Module $module) (get@ #.definitions) (get name)))] (if (and (macro? def-anns) (or (export? def-anns) (text/= module this-module))) - (#.Some (:! Macro def-value)) + (#.Some (:coerce Macro def-value)) (case (get-symbol-ann (ident-for #.alias) def-anns) (#.Some [r-module r-name]) (find-macro' modules this-module r-module r-name) @@ -539,7 +539,7 @@ (-> Ident (Meta Type)) (do Monad<Meta> [[def-type def-data def-value] (find-def name)] - (wrap (:! Type def-value)))) + (wrap (:coerce Type def-value)))) (def: #export (definitions module-name) {#.doc "The entire list of definitions in a module (including the unexported/private ones)."} diff --git a/stdlib/source/lux/world/blob.jvm.lux b/stdlib/source/lux/world/blob.jvm.lux index df9fcf8d2..4565e5499 100644 --- a/stdlib/source/lux/world/blob.jvm.lux +++ b/stdlib/source/lux/world/blob.jvm.lux @@ -27,7 +27,7 @@ (def: i64 (-> (primitive "java.lang.Byte") I64) - (|>> host.byte-to-long (:! I64) (bit.and byte-mask))) + (|>> host.byte-to-long (:coerce I64) (bit.and byte-mask))) (def: byte (-> (I64 Any) (primitive "java.lang.Byte")) @@ -134,7 +134,7 @@ (ex.throw index-out-of-bounds <description>) ## else - (#e.Success (Arrays::copyOfRange [blob (:! Int from) (:! Int (inc to))])))))) + (#e.Success (Arrays::copyOfRange [blob (:coerce Int from) (:coerce Int (inc to))])))))) (def: #export (slice' from blob) (-> Nat Blob (e.Error Blob)) diff --git a/stdlib/source/lux/world/console.lux b/stdlib/source/lux/world/console.lux index b66dce4da..49432f777 100644 --- a/stdlib/source/lux/world/console.lux +++ b/stdlib/source/lux/world/console.lux @@ -82,7 +82,7 @@ (wrap (StringBuffer::toString [] buffer)))) _ - (exec (Appendable::append [(:! String char)] buffer) + (exec (Appendable::append [(:coerce String char)] buffer) (recur [])))))))) (def: (write message) |