aboutsummaryrefslogtreecommitdiff
path: root/lux-scheme
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lux-scheme/source/program.lux142
1 files changed, 71 insertions, 71 deletions
diff --git a/lux-scheme/source/program.lux b/lux-scheme/source/program.lux
index 50d4e2220..7689755c5 100644
--- a/lux-scheme/source/program.lux
+++ b/lux-scheme/source/program.lux
@@ -139,10 +139,10 @@
(def: (variant? value)
(-> Any Bit)
- (case (ffi.check [java/lang/Object] (:as java/lang/Object value))
+ (case (ffi.check [java/lang/Object] (as java/lang/Object value))
{.#Some array}
... TODO: Get rid of this coercion ASAP.
- (let [array (:as (Array java/lang/Object) array)]
+ (let [array (as (Array java/lang/Object) array)]
(and (n.= 3 (array.size array))
(case (array.read! 0 array)
{.#Some tag}
@@ -178,7 +178,7 @@
... Methods
(program/VariantValue
[] (getValue self []) java/lang/Object
- (:as java/lang/Object value))
+ (as java/lang/Object value))
(gnu/lists/Pair
[] (getCar self []) java/lang/Object
(if cdr?
@@ -191,7 +191,7 @@
(|> value
(array.read! 0)
maybe.trusted
- (:as java/lang/Integer)
+ (as java/lang/Integer)
gnu/math/IntNum::new)))
(gnu/lists/Pair
[] (getCdr self []) java/lang/Object
@@ -209,14 +209,14 @@
... Methods
(program/TupleValue
[] (getValue self []) java/lang/Object
- (:as java/lang/Object value))
+ (as java/lang/Object value))
(gnu/lists/SimpleVector
[] (getBufferLength self []) int
(ffi.long_to_int (array.size value)))
(gnu/lists/SimpleVector
[] (getRaw self [idx int]) java/lang/Object
(|> value
- (array.read! (|> idx java/lang/Integer::longValue (:as Nat)))
+ (array.read! (|> idx java/lang/Integer::longValue (as Nat)))
maybe.trusted
lux_value))
(gnu/lists/SimpleVector
@@ -252,8 +252,8 @@
{.#Some value}
... TODO: Get rid of the coercions below.
(if (variant? value)
- (variant_value lux_value false (:as (Array java/lang/Object) value))
- (tuple_value lux_value (:as (Array java/lang/Object) value)))
+ (variant_value lux_value false (as (Array java/lang/Object) value))
+ (tuple_value lux_value (as (Array java/lang/Object) value)))
{.#None})
value))
@@ -263,40 +263,40 @@
(def: (variant tag flag value)
(-> Nat Bit Any Any)
- [(java/lang/Long::intValue (:as java/lang/Long tag))
- (: Any
- (if flag
- synthesis.unit
- (ffi.null)))
+ [(java/lang/Long::intValue (as java/lang/Long tag))
+ (is Any
+ (if flag
+ synthesis.unit
+ (ffi.null)))
value])
(def: (read_variant read host_object)
(-> (Reader java/lang/Object) (Reader gnu/lists/Pair))
(do try.monad
[tag (read (gnu/lists/Pair::getCar host_object))
- #let [host_object (:as gnu/lists/Pair (gnu/lists/Pair::getCdr host_object))
+ #let [host_object (as gnu/lists/Pair (gnu/lists/Pair::getCdr host_object))
flag (case (ffi.check java/lang/Boolean (gnu/lists/Pair::getCar host_object))
{.#Some flag}
- (:as Bit flag)
+ (as Bit flag)
{.#None}
(undefined))]
value (read (gnu/lists/Pair::getCdr host_object))]
- (wrap (..variant (:as Nat tag) flag value))))
+ (wrap (..variant (as Nat tag) flag value))))
(def: (read_tuple read host_object)
(-> (Reader java/lang/Object) (Reader (gnu/lists/FVector java/lang/Object)))
(let [size (.nat (gnu/lists/FVector::getBufferLength host_object))]
(loop [idx 0
- output (: (Array Any)
- (array.new size))]
+ output (is (Array Any)
+ (array.new size))]
(if (n.< size idx)
(case (read (gnu/lists/FVector::getRaw (.int idx) host_object))
{try.#Failure error}
{try.#Failure error}
{try.#Success lux_value}
- (again (++ idx) (array.write! idx (: Any lux_value) output)))
+ (again (++ idx) (array.write! idx (is Any lux_value) output)))
{try.#Success output}))))
(def: (read host_object)
@@ -336,7 +336,7 @@
{.#None})
(case (ffi.check gnu/lists/FVector host_object)
{.#Some host_object}
- (read_tuple read (:as (gnu/lists/FVector java/lang/Object) host_object))
+ (read_tuple read (as (gnu/lists/FVector java/lang/Object) host_object))
{.#None})
... else
@@ -344,62 +344,62 @@
(def: ensure_macro
(-> Macro (Maybe gnu/mapping/Procedure))
- (|>> (:as java/lang/Object) (ffi.check gnu/mapping/Procedure)))
+ (|>> (as java/lang/Object) (ffi.check gnu/mapping/Procedure)))
(def: (expander macro inputs lux)
Expander
(case (..ensure_macro macro)
{.#Some macro}
- (case (gnu/mapping/Procedure::apply2 (lux_value (:as java/lang/Object inputs))
- (lux_value (:as java/lang/Object lux))
+ (case (gnu/mapping/Procedure::apply2 (lux_value (as java/lang/Object inputs))
+ (lux_value (as java/lang/Object lux))
macro)
{try.#Success output}
(|> output
..read
- (:as (Try (Try [Lux (List Code)]))))
+ (as (Try (Try [Lux (List Code)]))))
{try.#Failure error}
{try.#Failure error})
{.#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 _.Expression))
(io (let [interpreter (kawa/standard/Scheme::getR7rsInstance)
- run! (: (-> (_.Code Any) (Try Any))
- (function (_ input)
- (do try.monad
- [output (gnu/expr/Language::eval (_.code input) interpreter)]
- (read output))))]
- (: (Host _.Expression _.Expression)
- (structure
- (def: (evaluate! context code)
- (run! code))
-
- (def: (execute! input)
- (gnu/expr/Language::eval (_.code input) interpreter))
-
- (def: (define! context input)
- (let [global (reference.artifact context)
- @global (_.var global)]
- (do try.monad
- [#let [definition (_.define_constant @global input)]
- _ (gnu/expr/Language::eval (_.code definition) interpreter)
- value (run! @global)]
- (wrap [global value definition]))))
-
- (def: (ingest context content)
- (|> content (# encoding.utf8 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 (_ input)
+ (do try.monad
+ [output (gnu/expr/Language::eval (_.code input) interpreter)]
+ (read output))))]
+ (is (Host _.Expression _.Expression)
+ (structure
+ (def: (evaluate! context code)
+ (run! code))
+
+ (def: (execute! input)
+ (gnu/expr/Language::eval (_.code input) interpreter))
+
+ (def: (define! context input)
+ (let [global (reference.artifact context)
+ @global (_.var global)]
+ (do try.monad
+ [#let [definition (_.define_constant @global input)]
+ _ (gnu/expr/Language::eval (_.code definition) interpreter)
+ value (run! @global)]
+ (wrap [global value definition]))))
+
+ (def: (ingest context content)
+ (|> content (# encoding.utf8 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 (Platform _.Var _.Expression _.Expression))
@@ -424,31 +424,31 @@
(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)
(do try.monad
- [handler (try.from_maybe (..ensure_macro (:as Macro handler)))
- output (gnu/mapping/Procedure::applyN (array.from_list (list (lux_value (:as java/lang/Object name))
- (lux_value (:as java/lang/Object phase))
- (lux_value (:as java/lang/Object archive))
- (lux_value (:as java/lang/Object parameters))
- (lux_value (:as java/lang/Object state))))
+ [handler (try.from_maybe (..ensure_macro (as Macro handler)))
+ output (gnu/mapping/Procedure::applyN (array.from_list (list (lux_value (as java/lang/Object name))
+ (lux_value (as java/lang/Object phase))
+ (lux_value (as java/lang/Object archive))
+ (lux_value (as java/lang/Object parameters))
+ (lux_value (as java/lang/Object state))))
handler)]
(..read output))))
@.scheme
(def: (extender handler)
Extender
- (:expected handler)))
+ (as_expected handler)))
(def: (declare_success! _)
(-> Any (Promise Any))