aboutsummaryrefslogtreecommitdiff
path: root/lux-ruby/source
diff options
context:
space:
mode:
Diffstat (limited to 'lux-ruby/source')
-rw-r--r--lux-ruby/source/program.lux234
1 files changed, 117 insertions, 117 deletions
diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux
index 3b8d46737..198faf43b 100644
--- a/lux-ruby/source/program.lux
+++ b/lux-ruby/source/program.lux
@@ -236,8 +236,8 @@
(-> Translator org/jruby/RubyArray (Try Any))
(let [size (.nat (ffi.of_int (org/jruby/RubyArray::getLength host_object)))]
(loop [idx 0
- output (: (Array Any)
- (array.empty size))]
+ output (is (Array Any)
+ (array.empty size))]
(if (n.< size idx)
(case (org/jruby/RubyArray::get (ffi.as_int (.int idx)) host_object)
{.#None}
@@ -265,21 +265,21 @@
[{.#Some tag} ?flag {.#Some value}]
(do try.monad
[value (read value)]
- (in [(: Any (|> tag
- (:as java/lang/Long)
- java/lang/Long::intValue
- (: java/lang/Integer)))
- (: Any
- (case ?flag
- {.#Some _}
- ""
-
- {.#None}
- (: java/lang/Object (ffi.null))))
- (: Any value)]))
+ (in [(is Any (|> tag
+ (as java/lang/Long)
+ java/lang/Long::intValue
+ (is java/lang/Integer)))
+ (is Any
+ (case ?flag
+ {.#Some _}
+ ""
+
+ {.#None}
+ (is java/lang/Object (ffi.null))))
+ (is Any value)]))
_
- (exception.except ..unknown_kind_of_object [(ffi.:as java/lang/Object host_object)])))
+ (exception.except ..unknown_kind_of_object [(ffi.as java/lang/Object host_object)])))
(exception: .public nil_has_no_lux_representation)
@@ -317,7 +317,7 @@
(def: lux_unit
org/jruby/runtime/builtin/IRubyObject
- (<| (ffi.:as org/jruby/runtime/builtin/IRubyObject)
+ (<| (ffi.as org/jruby/runtime/builtin/IRubyObject)
(org/jruby/RubyString::newInternalFromJavaExternal ..initial_ruby_runtime (ffi.as_string ""))))
(def: (wrapped_lux_value useful_object_class lux_structure)
@@ -332,22 +332,22 @@
{.#Some value}
(|> value
<then>
- (ffi.:as org/jruby/runtime/builtin/IRubyObject))
+ (ffi.as org/jruby/runtime/builtin/IRubyObject))
{.#None})]
- [[java/lang/Object] (<| lux_structure (:as (Array java/lang/Object)))]
+ [[java/lang/Object] (<| lux_structure (as (Array java/lang/Object)))]
[java/lang/Boolean (org/jruby/RubyBoolean::newBoolean ..initial_ruby_runtime)]
[java/lang/Long (org/jruby/RubyFixnum::new ..initial_ruby_runtime)]
[java/lang/Double (org/jruby/RubyFloat::new ..initial_ruby_runtime)]
[java/lang/String (org/jruby/RubyString::newInternalFromJavaExternal ..initial_ruby_runtime)]
[org/jruby/runtime/builtin/IRubyObject (<|)]
))
- ... (:as org/jruby/runtime/builtin/IRubyObject value)
- (<| (ffi.:as org/jruby/runtime/builtin/IRubyObject)
+ ... (as org/jruby/runtime/builtin/IRubyObject value)
+ (<| (ffi.as org/jruby/runtime/builtin/IRubyObject)
(org/jruby/java/proxies/JavaProxy::new ..initial_ruby_runtime
- (useful_object_class again (:as (Array java/lang/Object) value))
- (ffi.:as java/lang/Object value)))))))
+ (useful_object_class again (as (Array java/lang/Object) value))
+ (ffi.as java/lang/Object value)))))))
(exception: (invalid_variant_access [field Text])
(exception.report
@@ -377,7 +377,7 @@
org/jruby/RubyClass)
(-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject)
(-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod))
- (<| (ffi.:as org/jruby/internal/runtime/methods/DynamicMethod)
+ (<| (ffi.as org/jruby/internal/runtime/methods/DynamicMethod)
(ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod []
[java/lang/String (ffi.as_string "call")]
@@ -401,43 +401,43 @@
list.indices
(list#each (function (_ index)
(ffi.read! index args)))
- (monad.each ! (|>> (ffi.:as java/lang/Object) ..read)))
+ (monad.each ! (|>> (ffi.as java/lang/Object) ..read)))
output (case args
(pattern (list arg/0))
- (in ((:as (-> Any java/lang/Object) value)
+ (in ((as (-> Any java/lang/Object) value)
arg/0))
(pattern (list arg/0 arg/1))
- (in ((:as (-> Any Any java/lang/Object) value)
+ (in ((as (-> Any Any java/lang/Object) value)
arg/0 arg/1))
(pattern (list arg/0 arg/1 arg/2))
- (in ((:as (-> Any Any Any java/lang/Object) value)
+ (in ((as (-> Any Any Any java/lang/Object) value)
arg/0 arg/1 arg/2))
(pattern (list arg/0 arg/1 arg/2 arg/3))
- (in ((:as (-> Any Any Any Any java/lang/Object) value)
+ (in ((as (-> Any Any Any Any java/lang/Object) value)
arg/0 arg/1 arg/2 arg/3))
(pattern (list arg/0 arg/1 arg/2 arg/3 arg/4))
- (in ((:as (-> Any Any Any Any Any java/lang/Object) value)
+ (in ((as (-> Any Any Any Any Any java/lang/Object) value)
arg/0 arg/1 arg/2 arg/3 arg/4))
(pattern (list arg/0 arg/1 arg/2 arg/3 arg/4 arg/5))
- (in ((:as (-> Any Any Any Any Any Any java/lang/Object) value)
+ (in ((as (-> Any Any Any Any Any Any java/lang/Object) value)
arg/0 arg/1 arg/2 arg/3 arg/4 arg/5))
(pattern (list arg/0 arg/1 arg/2 arg/3 arg/4 arg/5 arg/6))
- (in ((:as (-> Any Any Any Any Any Any Any java/lang/Object) value)
+ (in ((as (-> Any Any Any Any Any Any Any java/lang/Object) value)
arg/0 arg/1 arg/2 arg/3 arg/4 arg/5 arg/6))
(pattern (list arg/0 arg/1 arg/2 arg/3 arg/4 arg/5 arg/6 arg/7))
- (in ((:as (-> Any Any Any Any Any Any Any Any java/lang/Object) value)
+ (in ((as (-> Any Any Any Any Any Any Any Any java/lang/Object) value)
arg/0 arg/1 arg/2 arg/3 arg/4 arg/5 arg/6 arg/7))
_
(exception.except ..invalid_arity [arity]))]
- (in (wrapped_lux_value (:expected useful_object_class) lux_structure output)))))))))
+ (in (wrapped_lux_value (as_expected useful_object_class) lux_structure output)))))))))
(def: (::access useful_object_class lux_structure value)
(-> (-> (-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject)
@@ -445,7 +445,7 @@
org/jruby/RubyClass)
(-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject)
(-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod))
- (<| (ffi.:as org/jruby/internal/runtime/methods/DynamicMethod)
+ (<| (ffi.as org/jruby/internal/runtime/methods/DynamicMethod)
(ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod []
[java/lang/String (ffi.as_string "[]")]
@@ -467,7 +467,7 @@
{.#Some member}
(case (array.read! (.nat (ffi.of_long (org/jruby/RubyFixnum::getLongValue member))) value)
{.#Some value}
- (wrapped_lux_value (:expected useful_object_class) lux_structure value)
+ (wrapped_lux_value (as_expected useful_object_class) lux_structure value)
{.#None}
..ruby_nil)
@@ -480,10 +480,10 @@
(|> value
(array.read! 0)
maybe.trusted
- (:as java/lang/Integer)
+ (as java/lang/Integer)
java/lang/Integer::longValue
(org/jruby/RubyFixnum::new ..initial_ruby_runtime)
- (ffi.:as org/jruby/runtime/builtin/IRubyObject))
+ (ffi.as org/jruby/runtime/builtin/IRubyObject))
(pattern (static runtime.variant_flag_field))
(case (array.read! 1 value)
@@ -496,7 +496,7 @@
(pattern (static runtime.variant_value_field))
(case (array.read! 2 value)
{.#Some value}
- (wrapped_lux_value (:expected useful_object_class) lux_structure value)
+ (wrapped_lux_value (as_expected useful_object_class) lux_structure value)
{.#None}
(panic! (exception.error ..nil_has_no_lux_representation [])))
@@ -515,14 +515,14 @@
(lux_structure (java/util/Arrays::copyOfRange value (ffi.as_int first) (ffi.as_int (i.+ first size)))))
_
- (panic! (exception.error ..invalid_index [(ffi.:as java/lang/Object member)])))
+ (panic! (exception.error ..invalid_index [(ffi.as java/lang/Object member)])))
{.#None})
- (panic! (exception.error ..invalid_index [(ffi.:as java/lang/Object member)]))))))))
+ (panic! (exception.error ..invalid_index [(ffi.as java/lang/Object member)]))))))))
(def: (::= value)
(-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod)
- (<| (ffi.:as org/jruby/internal/runtime/methods/DynamicMethod)
+ (<| (ffi.as org/jruby/internal/runtime/methods/DynamicMethod)
(ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod []
[java/lang/String (ffi.as_string "==")]
@@ -539,22 +539,22 @@
args [org/jruby/runtime/builtin/IRubyObject]
block org/jruby/runtime/Block])
org/jruby/runtime/builtin/IRubyObject
- (<| (ffi.:as org/jruby/runtime/builtin/IRubyObject)
+ (<| (ffi.as org/jruby/runtime/builtin/IRubyObject)
(org/jruby/RubyBoolean::newBoolean ..initial_ruby_runtime)
ffi.as_boolean
(case (|> args
(ffi.read! 0)
- (ffi.:as java/lang/Object)
+ (ffi.as java/lang/Object)
..read)
{try.#Success reference}
- (same? (: Any reference) (: Any value))
+ (same? (is Any reference) (is Any value))
{try.#Failure error}
false))))))
(def: (::length value)
(-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod)
- (<| (ffi.:as org/jruby/internal/runtime/methods/DynamicMethod)
+ (<| (ffi.as org/jruby/internal/runtime/methods/DynamicMethod)
(ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod []
[java/lang/String (ffi.as_string "length")]
@@ -576,11 +576,11 @@
.int
ffi.as_long
(org/jruby/RubyFixnum::new ..initial_ruby_runtime)
- (ffi.:as org/jruby/runtime/builtin/IRubyObject))))))
+ (ffi.as org/jruby/runtime/builtin/IRubyObject))))))
(def: (::to_s value)
(-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod)
- (<| (ffi.:as org/jruby/internal/runtime/methods/DynamicMethod)
+ (<| (ffi.as org/jruby/internal/runtime/methods/DynamicMethod)
(ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod []
[java/lang/String (ffi.as_string "to_s")]
@@ -601,7 +601,7 @@
debug.inspection
ffi.as_string
(org/jruby/RubyString::newInternalFromJavaExternal ..initial_ruby_runtime)
- (ffi.:as org/jruby/runtime/builtin/IRubyObject))))))
+ (ffi.as org/jruby/runtime/builtin/IRubyObject))))))
(exception: (invalid_operation [method Text])
(exception.report
@@ -609,7 +609,7 @@
(def: (::respond_to? value)
(-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod)
- (<| (ffi.:as org/jruby/internal/runtime/methods/DynamicMethod)
+ (<| (ffi.as org/jruby/internal/runtime/methods/DynamicMethod)
(ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod []
[java/lang/String (ffi.as_string "respond_to?")]
@@ -644,7 +644,7 @@
false)
ffi.as_boolean
(org/jruby/RubyBoolean::newBoolean ..initial_ruby_runtime)
- (ffi.:as org/jruby/runtime/builtin/IRubyObject))
+ (ffi.as org/jruby/runtime/builtin/IRubyObject))
{.#None}
(panic! (exception.error ..invalid_operation ["respond_to?"])))))))
@@ -657,7 +657,7 @@
(-> (-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject)
(Array java/lang/Object)
org/jruby/RubyClass)
- (<| (ffi.:as org/jruby/RubyClass)
+ (<| (ffi.as org/jruby/RubyClass)
(ffi.object [] org/jruby/RubyClass []
[org/jruby/Ruby ..initial_ruby_runtime]
@@ -688,10 +688,10 @@
(def: (lux_structure value)
(-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject)
- (<| (ffi.:as org/jruby/runtime/builtin/IRubyObject)
+ (<| (ffi.as org/jruby/runtime/builtin/IRubyObject)
(org/jruby/java/proxies/JavaProxy::new ..initial_ruby_runtime
(useful_object_class lux_structure value)
- (ffi.:as java/lang/Object value))))
+ (ffi.as java/lang/Object value))))
(exception: (cannot_apply_a_non_function [object java/lang/Object])
(exception.report
@@ -699,24 +699,24 @@
(def: macro!
(-> Macro (Maybe org/jruby/RubyProc))
- (|>> (:as java/lang/Object)
+ (|>> (as java/lang/Object)
(ffi.check org/jruby/RubyProc)))
(def: to_host
(-> Any org/jruby/runtime/builtin/IRubyObject)
- (|>> (:as (Array java/lang/Object))
+ (|>> (as (Array java/lang/Object))
..lux_structure))
(def: (call_macro inputs lux macro)
(-> (List Code) Lux org/jruby/RubyProc (Try (Try [Lux (List Code)])))
- (:expected
+ (as_expected
(do try.monad
[expansion (org/jruby/RubyProc::call (!ruby_thread_context)
(|> (ffi.array org/jruby/runtime/builtin/IRubyObject 2)
(ffi.write! 0 (..to_host inputs))
(ffi.write! 1 (..to_host lux)))
macro)]
- (..read (ffi.:as java/lang/Object expansion)))))
+ (..read (ffi.as java/lang/Object expansion)))))
(def: (expander macro inputs lux)
Expander
@@ -725,53 +725,53 @@
(case (call_macro inputs lux macro)
{try.#Success output}
(|> output
- (:as java/lang/Object)
+ (as java/lang/Object)
..read
- (:as (Try (Try [Lux (List Code)]))))
+ (as (Try (Try [Lux (List Code)]))))
{try.#Failure error}
{try.#Failure error})
{.#None}
- (exception.except ..cannot_apply_a_non_function [(:as java/lang/Object macro)])))
+ (exception.except ..cannot_apply_a_non_function [(as java/lang/Object macro)])))
(def: host
(IO (Host _.Expression _.Statement))
- (io (let [run! (: (-> (_.Code Any) (Try Any))
- (function (_ code)
- (do try.monad
- [output (org/jruby/embed/ScriptingContainer::runScriptlet (ffi.as_string (_.code code)) ..interpreter)]
- (..read (maybe.else (:as java/lang/Object [])
- output)))))]
- (: (Host _.Expression _.Statement)
- (implementation
- (def: (evaluate context [_ code])
- (run! code))
-
- (def: execute run!)
-
- (def: (define context custom [_ input])
- (let [global (maybe.else (reference.artifact context)
- custom)
- @global (_.global global)]
- (do try.monad
- [.let [definition (_.set (list @global) input)]
- value (run! definition)]
- (in [global value definition]))))
-
- (def: (ingest context content)
- (|> content
- (# utf8.codec decoded)
- try.trusted
- (:as _.Statement)))
-
- (def: (re_learn context custom content)
- (run! content))
-
- (def: (re_load context custom content)
- (do try.monad
- [_ (run! content)]
- (run! (_.global (reference.artifact context))))))))))
+ (io (let [run! (is (-> (_.Code Any) (Try Any))
+ (function (_ code)
+ (do try.monad
+ [output (org/jruby/embed/ScriptingContainer::runScriptlet (ffi.as_string (_.code code)) ..interpreter)]
+ (..read (maybe.else (as java/lang/Object [])
+ output)))))]
+ (is (Host _.Expression _.Statement)
+ (implementation
+ (def: (evaluate context [_ code])
+ (run! code))
+
+ (def: execute run!)
+
+ (def: (define context custom [_ input])
+ (let [global (maybe.else (reference.artifact context)
+ custom)
+ @global (_.global global)]
+ (do try.monad
+ [.let [definition (_.set (list @global) input)]
+ value (run! definition)]
+ (in [global value definition]))))
+
+ (def: (ingest context content)
+ (|> content
+ (# utf8.codec decoded)
+ try.trusted
+ (as _.Statement)))
+
+ (def: (re_learn context custom content)
+ (run! content))
+
+ (def: (re_load context custom content)
+ (do try.monad
+ [_ (run! content)]
+ (run! (_.global (reference.artifact context))))))))))
(for @.jvm (as_is (exception: .public (invaid_phase_application [partial_application (List Any)
arity (List Any)])
@@ -795,7 +795,7 @@
(def: phase_block_body
org/jruby/runtime/BlockBody
- (<| (ffi.:as org/jruby/runtime/BlockBody)
+ (<| (ffi.as org/jruby/runtime/BlockBody)
(ffi.object [] org/jruby/runtime/BlockBody []
[org/jruby/runtime/Signature ..phase_block_signature]
... Methods
@@ -851,13 +851,13 @@
(do [! try.monad]
[inputs (|> inputs
(array.list {.#None})
- (monad.each ! (|>> (ffi.:as java/lang/Object) ..read)))])
+ (monad.each ! (|>> (ffi.as java/lang/Object) ..read)))])
(case inputs
... It seems that org/jruby/runtime/Block::call can misbehave when getting called with a Lux state value.
(pattern (list info source location current_module modules scopes type_context expected seed scope_type_vars extensions eval host))
(case partial_application
(pattern (list partial/0 partial/1))
- (in (..to_host ((:as (-> Any Any Any Any) phase)
+ (in (..to_host ((as (-> Any Any Any Any) phase)
partial/0
partial/1
[info source location current_module modules scopes type_context expected seed scope_type_vars extensions eval host])))
@@ -866,21 +866,21 @@
(exception.except ..invaid_phase_application [partial_application inputs]))
(pattern (list))
- {try.#Success (<| (ffi.:as org/jruby/runtime/builtin/IRubyObject)
+ {try.#Success (<| (ffi.as org/jruby/runtime/builtin/IRubyObject)
(host_phase partial_application phase))}
(pattern (list input/0))
(case partial_application
(pattern (list))
- (in (<| (ffi.:as org/jruby/runtime/builtin/IRubyObject)
+ (in (<| (ffi.as org/jruby/runtime/builtin/IRubyObject)
(host_phase (list input/0) phase)))
(pattern (list partial/0))
- (in (<| (ffi.:as org/jruby/runtime/builtin/IRubyObject)
+ (in (<| (ffi.as org/jruby/runtime/builtin/IRubyObject)
(host_phase (list partial/0 input/0) phase)))
(pattern (list partial/0 partial/1))
- (in (..to_host ((:as (-> Any Any Any Any) phase)
+ (in (..to_host ((as (-> Any Any Any Any) phase)
partial/0
partial/1
input/0)))
@@ -891,11 +891,11 @@
(pattern (list input/0 input/1))
(case partial_application
(pattern (list))
- (in (<| (ffi.:as org/jruby/runtime/builtin/IRubyObject)
+ (in (<| (ffi.as org/jruby/runtime/builtin/IRubyObject)
(host_phase (list input/0 input/1) phase)))
(pattern (list partial/0))
- (in (..to_host ((:as (-> Any Any Any Any) phase)
+ (in (..to_host ((as (-> Any Any Any Any) phase)
partial/0
input/0
input/1)))
@@ -906,7 +906,7 @@
(pattern (list input/0 input/1 input/2))
(case partial_application
(pattern (list))
- (in (..to_host ((:as (-> Any Any Any Any) phase)
+ (in (..to_host ((as (-> Any Any Any Any) phase)
input/0
input/1
input/2)))
@@ -921,39 +921,39 @@
(def: (extender phase_wrapper)
(-> phase.Wrapper 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.of_maybe (..macro! handler))
output (org/jruby/RubyProc::call (!ruby_thread_context)
(|> (ffi.array org/jruby/runtime/builtin/IRubyObject 5)
- (ffi.write! 0 (<| (ffi.:as org/jruby/runtime/builtin/IRubyObject)
+ (ffi.write! 0 (<| (ffi.as org/jruby/runtime/builtin/IRubyObject)
(org/jruby/RubyString::newInternalFromJavaExternal (!ruby_runtime) (ffi.as_string name))))
- (ffi.write! 1 (:as org/jruby/runtime/builtin/IRubyObject (phase_wrapper phase)))
+ (ffi.write! 1 (as org/jruby/runtime/builtin/IRubyObject (phase_wrapper phase)))
(ffi.write! 2 (..to_host archive))
(ffi.write! 3 (..to_host parameters))
(ffi.write! 4 (..to_host state)))
handler)]
- (..read (ffi.:as java/lang/Object output))))))
+ (..read (ffi.as java/lang/Object output))))))
@.ruby
(def: (extender phase_wrapper handler)
(-> phase.Wrapper Extender)
- (:expected handler)))
+ (as_expected handler)))
(def: (phase_wrapper archive)
(-> Archive (runtime.Operation phase.Wrapper))
(<| phase#in
- (:as phase.Wrapper)
+ (as phase.Wrapper)
(for @.jvm (..host_phase (list))
@.ruby (|>>))))
@@ -973,7 +973,7 @@
(let [normal_runtime? (_.do "const_defined?"
(list (_.string (_.code _.command_line_arguments)))
{.#None}
- (: _.CVar (_.manual "Object")))]
+ (is _.CVar (_.manual "Object")))]
(_.statement
(_.apply_lambda/* (list (runtime.lux//program_args (_.? normal_runtime?
_.command_line_arguments