aboutsummaryrefslogtreecommitdiff
path: root/lux-cl/source
diff options
context:
space:
mode:
Diffstat (limited to 'lux-cl/source')
-rw-r--r--lux-cl/source/program.lux150
1 files changed, 75 insertions, 75 deletions
diff --git a/lux-cl/source/program.lux b/lux-cl/source/program.lux
index c64c0f97b..5e01060b3 100644
--- a/lux-cl/source/program.lux
+++ b/lux-cl/source/program.lux
@@ -169,47 +169,47 @@
(def: (host_value value)
(-> Any org/armedbear/lisp/LispObject)
- (let [to_sub (: (-> Any org/armedbear/lisp/LispObject)
- (function (_ sub_value)
- (let [sub_value (:as java/lang/Object sub_value)]
- (`` (<| (~~ (template [<type> <then>]
- [(case (ffi.check <type> sub_value)
- {.#Some sub_value}
- (`` (|> sub_value (~~ (template.splice <then>))))
-
- {.#None})]
-
- [[java/lang/Object] [host_value]]
- [java/lang/Boolean [..host_bit]]
- [java/lang/Integer [java/lang/Integer::longValue org/armedbear/lisp/Fixnum::getInstance]]
- [java/lang/Long [org/armedbear/lisp/Bignum::getInstance]]
- [java/lang/Double [org/armedbear/lisp/DoubleFloat::new]]
- [java/lang/String [org/armedbear/lisp/SimpleString::new]]
- ))
- ... else
- (:as org/armedbear/lisp/LispObject sub_value))))))]
+ (let [to_sub (is (-> Any org/armedbear/lisp/LispObject)
+ (function (_ sub_value)
+ (let [sub_value (as java/lang/Object sub_value)]
+ (`` (<| (~~ (template [<type> <then>]
+ [(case (ffi.check <type> sub_value)
+ {.#Some sub_value}
+ (`` (|> sub_value (~~ (template.splice <then>))))
+
+ {.#None})]
+
+ [[java/lang/Object] [host_value]]
+ [java/lang/Boolean [..host_bit]]
+ [java/lang/Integer [java/lang/Integer::longValue org/armedbear/lisp/Fixnum::getInstance]]
+ [java/lang/Long [org/armedbear/lisp/Bignum::getInstance]]
+ [java/lang/Double [org/armedbear/lisp/DoubleFloat::new]]
+ [java/lang/String [org/armedbear/lisp/SimpleString::new]]
+ ))
+ ... else
+ (as org/armedbear/lisp/LispObject sub_value))))))]
(`` (ffi.object [] org/armedbear/lisp/LispObject [program/LuxADT]
[]
... Methods
(program/LuxADT
[] (getValue self []) java/lang/Object
- (:as java/lang/Object value))
+ (as java/lang/Object value))
(org/armedbear/lisp/LispObject
[] (length self [])
int
(|> value
- (:as (Array java/lang/Object))
+ (as (Array java/lang/Object))
array.size
- (:as java/lang/Long)
+ (as java/lang/Long)
java/lang/Number::intValue))
(~~ (template [<name>]
[(org/armedbear/lisp/LispObject
[] (<name> self [idx int])
org/armedbear/lisp/LispObject
- (case (array.read! (|> idx java/lang/Integer::longValue (:as Nat))
- (:as (Array java/lang/Object) value))
+ (case (array.read! (|> idx java/lang/Integer::longValue (as Nat))
+ (as (Array java/lang/Object) value))
{.#Some sub}
(to_sub sub)
@@ -228,20 +228,20 @@
(do try.monad
[tag (read (org/armedbear/lisp/LispObject::NTH +0 host_object))
value (read (org/armedbear/lisp/LispObject::NTH +2 host_object))]
- (wrap [(java/lang/Long::intValue (:as java/lang/Long tag))
+ (wrap [(java/lang/Long::intValue (as java/lang/Long tag))
(case (ffi.check org/armedbear/lisp/Nil (org/armedbear/lisp/LispObject::NTH +1 host_object))
{.#Some _}
- (: Any (ffi.null))
+ (is Any (ffi.null))
_
- (: Any synthesis.unit))
+ (is Any synthesis.unit))
value])))
(def: (read_tuple read host_object)
(-> (Reader org/armedbear/lisp/LispObject) (Reader org/armedbear/lisp/SimpleVector))
(let [size (.nat (org/armedbear/lisp/LispObject::length host_object))]
(loop [idx 0
- output (:as (Array Any) (array.new size))]
+ output (as (Array Any) (array.new size))]
(if (n.< size idx)
... TODO: Start using "SVREF" instead of "elt" ASAP
(case (read (org/armedbear/lisp/LispObject::elt (.int idx) host_object))
@@ -249,7 +249,7 @@
{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: (read host_object)
@@ -274,23 +274,23 @@
{.#Some host_object}
(if (same? (org/armedbear/lisp/Symbol::T) host_object)
{try.#Success true}
- (exception.throw ..unknown_kind_of_object (:as java/lang/Object host_object)))
+ (exception.throw ..unknown_kind_of_object (as java/lang/Object host_object)))
{.#None})
... else
- (exception.throw ..unknown_kind_of_object (:as java/lang/Object host_object))
+ (exception.throw ..unknown_kind_of_object (as java/lang/Object host_object))
)))
(def: ensure_macro
(-> Macro (Maybe org/armedbear/lisp/Closure))
- (|>> (:as java/lang/Object) (ffi.check org/armedbear/lisp/Closure)))
+ (|>> (as java/lang/Object) (ffi.check org/armedbear/lisp/Closure)))
(def: (call_macro inputs lux macro)
(-> (List Code) Lux org/armedbear/lisp/Closure (Try (Try [Lux (List Code)])))
(do try.monad
[raw_output (org/armedbear/lisp/LispObject::execute (..host_value inputs) (..host_value lux) macro)]
- (:as (Try (Try [Lux (List Code)]))
- (..read raw_output))))
+ (as (Try (Try [Lux (List Code)]))
+ (..read raw_output))))
(def: (expander macro inputs lux)
Expander
@@ -299,45 +299,45 @@
(call_macro 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 (Host (_.Expression Any) (_.Expression Any)))
(io (let [_ (org/armedbear/lisp/Interpreter::createInstance)
interpreter (org/armedbear/lisp/Interpreter::getInstance)
- run! (: (-> (_.Code Any) (Try Any))
- (function (_ code)
- (do try.monad
- [host_value (org/armedbear/lisp/Interpreter::eval (_.code code) interpreter)]
- (read host_value))))]
- (: (Host (_.Expression Any) (_.Expression Any))
- (structure
- (def: (evaluate! context code)
- (run! code))
-
- (def: (execute! input)
- (org/armedbear/lisp/Interpreter::eval (_.code input) interpreter))
-
- (def: (define! context input)
- (let [global (reference.artifact context)
- @global (_.var global)]
- (do try.monad
- [#let [definition (_.defparameter @global input)]
- _ (org/armedbear/lisp/Interpreter::eval (_.code definition) interpreter)
- value (run! @global)]
- (wrap [global value definition]))))
-
- (def: (ingest context content)
- (|> content (# encoding.utf8 decoded) try.trusted (:as (_.Expression Any))))
-
- (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 (org/armedbear/lisp/Interpreter::eval (_.code code) interpreter)]
+ (read host_value))))]
+ (is (Host (_.Expression Any) (_.Expression Any))
+ (structure
+ (def: (evaluate! context code)
+ (run! code))
+
+ (def: (execute! input)
+ (org/armedbear/lisp/Interpreter::eval (_.code input) interpreter))
+
+ (def: (define! context input)
+ (let [global (reference.artifact context)
+ @global (_.var global)]
+ (do try.monad
+ [#let [definition (_.defparameter @global input)]
+ _ (org/armedbear/lisp/Interpreter::eval (_.code definition) interpreter)
+ value (run! @global)]
+ (wrap [global value definition]))))
+
+ (def: (ingest context content)
+ (|> content (# encoding.utf8 decoded) try.trusted (as (_.Expression Any))))
+
+ (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 (Platform [_.Tag Register] (_.Expression Any) (_.Expression Any)))
@@ -374,17 +374,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"})))
@@ -392,7 +392,7 @@
@.common_lisp
(def: (extender handler)
Extender
- (:expected handler)))
+ (as_expected handler)))
(def: (declare_success! _)
(-> Any (Promise Any))