aboutsummaryrefslogtreecommitdiff
path: root/lux-r/source
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lux-r/source/program.lux162
1 files changed, 81 insertions, 81 deletions
diff --git a/lux-r/source/program.lux b/lux-r/source/program.lux
index da00a6f02..77b3fc757 100644
--- a/lux-r/source/program.lux
+++ b/lux-r/source/program.lux
@@ -191,9 +191,9 @@
(def: (host_value value)
(-> Any org/renjin/sexp/SEXP)
- (let [... to_sub (: (-> Any org/armedbear/lisp/LispObject)
+ (let [... to_sub (is (-> Any org/armedbear/lisp/LispObject)
... (function (_ sub_value)
- ... (let [sub_value (:as java/lang/Object sub_value)]
+ ... (let [sub_value (as java/lang/Object sub_value)]
... (`` (<| (~~ (template [<type> <then>]
... [(case (ffi.check <type> sub_value)
... {.#Some sub_value}
@@ -208,7 +208,7 @@
... [java/lang/String [org/armedbear/lisp/SimpleString::new]]
... ))
... ... else
- ... (:as org/armedbear/lisp/LispObject sub_value))))))
+ ... (as org/armedbear/lisp/LispObject sub_value))))))
]
(`` (macro.log_expand_once!
(ffi.object []
@@ -221,12 +221,12 @@
[[org/renjin/sexp/SEXP] (ffi.array org/renjin/sexp/SEXP 0)
... (java/util/List java/lang/Object)
- ... (:expected (..fake_list []))
+ ... (as_expected (..fake_list []))
]
... Methods
... (program/LuxADT
... [] (getValue self []) java/lang/Object
- ... (:as java/lang/Object value))
+ ... (as java/lang/Object value))
... (org/renjin/sexp/AbstractSEXP
... [] (eval self [context org/renjin/eval/Context environment org/renjin/sexp/Environment])
@@ -360,21 +360,21 @@
(do try.monad
[tag (|> host_object
(org/renjin/sexp/ListVector::get_field runtime.variant_tag_field)
- (:as java/lang/Object)
+ (as java/lang/Object)
read)
value (|> host_object
(org/renjin/sexp/ListVector::get_field runtime.variant_value_field)
- (:as java/lang/Object)
+ (as java/lang/Object)
read)]
- (wrap [(|> tag (:as java/lang/Long) java/lang/Long::intValue)
+ (wrap [(|> tag (as java/lang/Long) java/lang/Long::intValue)
(case (|> host_object
(org/renjin/sexp/ListVector::get_field runtime.variant_flag_field)
(ffi.check org/renjin/sexp/Null))
{.#Some _}
- (: Any (ffi.null))
+ (is Any (ffi.null))
_
- (: Any synthesis.unit))
+ (is Any synthesis.unit))
value])))
(def: (read_i64 host_object)
@@ -396,14 +396,14 @@
(-> (Reader java/lang/Object) (Reader org/renjin/sexp/ListVector))
(let [size (.nat (org/renjin/sexp/ListVector::length host_object))]
(loop [idx 0
- output (:as (Array Any) (array.new size))]
+ output (as (Array Any) (array.new size))]
(if (n.< size idx)
- (case (|> host_object (org/renjin/sexp/ListVector::get_index (.int idx)) (:as java/lang/Object) read)
+ (case (|> host_object (org/renjin/sexp/ListVector::get_index (.int idx)) (as java/lang/Object) read)
{try.#Failure error}
{try.#Failure error}
{try.#Success member}
- (again (++ idx) (array.write! idx (:as Any member) output)))
+ (again (++ idx) (array.write! idx (as Any member) output)))
{try.#Success output}))))
(def: (field_class field host_object)
@@ -412,7 +412,7 @@
(org/renjin/sexp/ListVector::get_field field)
java/lang/Object::getClass
java/lang/Object::toString
- (:as Text)))
+ (as Text)))
(def: (read host_object)
(Reader java/lang/Object)
@@ -455,24 +455,24 @@
(def: ensure_macro
(-> Macro (Maybe org/renjin/sexp/Closure))
- (|>> (:as java/lang/Object) (ffi.check org/renjin/sexp/Closure)))
+ (|>> (as java/lang/Object) (ffi.check org/renjin/sexp/Closure)))
(def: (call_macro interpreter inputs lux macro)
(-> org/renjin/script/RenjinScriptEngine (List Code) Lux org/renjin/sexp/Closure (Try (Try [Lux (List Code)])))
(let [_ ("lux io log" "@call_macro 0")
- r_inputs (: org/renjin/sexp/PairList
- (case (ffi.try (|> (org/renjin/sexp/PairList$Builder::new)
- (org/renjin/sexp/PairList$Builder::add (..host_value inputs))
- (org/renjin/sexp/PairList$Builder::add (..host_value lux))
- org/renjin/sexp/PairList$Builder::build
- (:as org/renjin/sexp/PairList)))
- {try.#Success r_inputs}
- r_inputs
-
- {try.#Failure error}
- (exec
- ("lux io log" error)
- (panic! error))))
+ r_inputs (is org/renjin/sexp/PairList
+ (case (ffi.try (|> (org/renjin/sexp/PairList$Builder::new)
+ (org/renjin/sexp/PairList$Builder::add (..host_value inputs))
+ (org/renjin/sexp/PairList$Builder::add (..host_value lux))
+ org/renjin/sexp/PairList$Builder::build
+ (as org/renjin/sexp/PairList)))
+ {try.#Success r_inputs}
+ r_inputs
+
+ {try.#Failure error}
+ (exec
+ ("lux io log" error)
+ (panic! error))))
_ ("lux io log" "@call_macro 1")
r_macro (org/renjin/sexp/FunctionCall::new macro r_inputs)
_ ("lux io log" "@call_macro 2")
@@ -483,8 +483,8 @@
(do try.monad
[raw_output (org/renjin/sexp/FunctionCall::eval r_context r_environment r_macro)
#let [_ ("lux io log" "@call_macro 5")]]
- (:as (Try (Try [Lux (List Code)]))
- (..read (:as java/lang/Object raw_output))))))
+ (as (Try (Try [Lux (List Code)]))
+ (..read (as java/lang/Object raw_output))))))
(def: (expander interpreter macro inputs lux)
(-> org/renjin/script/RenjinScriptEngine Expander)
@@ -493,56 +493,56 @@
(call_macro interpreter inputs lux macro)
{.#None}
- (exception.throw ..cannot_apply_a_non_function [(:as java/lang/Object macro)])))
+ (exception.throw ..cannot_apply_a_non_function [(as java/lang/Object macro)])))
(def: host
(IO [org/renjin/script/RenjinScriptEngine
(Host _.Expression _.Expression)])
(io (let [interpreter (|> (org/renjin/script/RenjinScriptEngineFactory::new)
org/renjin/script/RenjinScriptEngineFactory::getScriptEngine)
- run! (: (-> (_.Code Any) (Try Any))
- (function (_ code)
- (do try.monad
- [host_value (javax/script/ScriptEngine::eval (_.code code) interpreter)]
- (read host_value))))]
- [(:as org/renjin/script/RenjinScriptEngine interpreter)
- (: (Host _.Expression _.Expression)
- (structure
- (def: (evaluate! context code)
- (exec ("lux io log" "@evaluate!")
- (run! code)))
-
- (def: (execute! input)
- (exec
- ("lux io log" "@execute!")
- ... ("lux io log" (_.code input))
- (javax/script/ScriptEngine::eval (_.code input) interpreter)))
-
- (def: (define! context input)
- (let [global (reference.artifact context)
- $global (_.var global)]
- (do try.monad
- [#let [definition (_.set! $global input)]
- #let [_ ("lux io log" "@define! 0")
- ... _ ("lux io log" (_.code definition))
- ]
- _ (javax/script/ScriptEngine::eval (_.code definition) interpreter)
- #let [_ ("lux io log" "@define! 1")]
- value (run! $global)
- #let [_ ("lux io log" "@define! 2")]]
- (wrap [global value definition]))))
-
- (def: (ingest context content)
- (|> content (# utf8.codec decoded) try.trusted (:as _.Expression)))
-
- (def: (re_learn context content)
- (run! content))
-
- (def: (re_load context content)
- (do try.monad
- [_ (run! content)]
- (run! (_.var (reference.artifact context)))))
- ))])))
+ run! (is (-> (_.Code Any) (Try Any))
+ (function (_ code)
+ (do try.monad
+ [host_value (javax/script/ScriptEngine::eval (_.code code) interpreter)]
+ (read host_value))))]
+ [(as org/renjin/script/RenjinScriptEngine interpreter)
+ (is (Host _.Expression _.Expression)
+ (structure
+ (def: (evaluate! context code)
+ (exec ("lux io log" "@evaluate!")
+ (run! code)))
+
+ (def: (execute! input)
+ (exec
+ ("lux io log" "@execute!")
+ ... ("lux io log" (_.code input))
+ (javax/script/ScriptEngine::eval (_.code input) interpreter)))
+
+ (def: (define! context input)
+ (let [global (reference.artifact context)
+ $global (_.var global)]
+ (do try.monad
+ [#let [definition (_.set! $global input)]
+ #let [_ ("lux io log" "@define! 0")
+ ... _ ("lux io log" (_.code definition))
+ ]
+ _ (javax/script/ScriptEngine::eval (_.code definition) interpreter)
+ #let [_ ("lux io log" "@define! 1")]
+ value (run! $global)
+ #let [_ ("lux io log" "@define! 2")]]
+ (wrap [global value definition]))))
+
+ (def: (ingest context content)
+ (|> content (# utf8.codec decoded) try.trusted (as _.Expression)))
+
+ (def: (re_learn context content)
+ (run! content))
+
+ (def: (re_load context content)
+ (do try.monad
+ [_ (run! content)]
+ (run! (_.var (reference.artifact context)))))
+ ))])))
(def: platform
(IO [org/renjin/script/RenjinScriptEngine
@@ -564,17 +564,17 @@
(def: extender
Extender
... TODO: Stop relying on coercions ASAP.
- (<| (:as Extender)
+ (<| (as Extender)
(function (@self handler))
- (:as Handler)
+ (as Handler)
(function (@self name phase))
- (:as Phase)
+ (as Phase)
(function (@self archive parameters))
- (:as Operation)
+ (as Operation)
(function (@self state))
- (:as Try)
+ (as Try)
try.trusted
- (:as Try)
+ (as Try)
(exec
("lux io log" "TODO: Extender")
{try.#Failure "TODO: Extender"})))
@@ -582,7 +582,7 @@
@.r
(def: (extender handler)
Extender
- (:expected handler)))
+ (as_expected handler)))
(def: (declare_success! _)
(-> Any (Promise Any))