aboutsummaryrefslogtreecommitdiff
path: root/lux-lua
diff options
context:
space:
mode:
authorEduardo Julian2022-03-14 06:14:57 -0400
committerEduardo Julian2022-03-14 06:14:57 -0400
commit4965597043aca57a05760113f1851e96dad1eaf8 (patch)
tree8126d3e6394e38bc52918eea95a67546350bb95e /lux-lua
parentcfd438517a46e025b15345e3570b02f5ea6165c0 (diff)
Leaner syntax for the "for" macro.
Diffstat (limited to 'lux-lua')
-rw-r--r--lux-lua/source/program.lux152
1 files changed, 76 insertions, 76 deletions
diff --git a/lux-lua/source/program.lux b/lux-lua/source/program.lux
index 6393f6fe1..631b55d9a 100644
--- a/lux-lua/source/program.lux
+++ b/lux-lua/source/program.lux
@@ -477,13 +477,13 @@
{.#None}
(exception.except ..cannot_apply_a_non_function (:as java/lang/Object macro)))))]
- (for [@.old (as_is <jvm>)
- @.jvm (as_is <jvm>)
+ (for @.old (as_is <jvm>)
+ @.jvm (as_is <jvm>)
- @.lua
- (def: (expander macro inputs lux)
- Expander
- {try.#Success ((:as Macro' macro) inputs lux)})]))
+ @.lua
+ (def: (expander macro inputs lux)
+ Expander
+ {try.#Success ((:as Macro' macro) inputs lux)})))
(with_expansions [<jvm> (as_is (with_expansions [$var_args (_.var "...")
$str_rel_to_abs (_.var "_utf8_str_rel_to_abs")
@@ -727,46 +727,46 @@
(do try.monad
[_ (run! content)]
(run! (_.return (_.var (reference.artifact context))))))))]))))]
- (for [@.old (as_is <jvm>)
- @.jvm (as_is <jvm>)
- @.lua (as_is (ffi.import: (load [ffi.String] "try" ffi.Function))
- (def: host
- (IO (Host _.Expression _.Statement))
- (io (let [run! (: (-> _.Statement (Try Any))
- (function (_ code)
- (do try.monad
- [lua_function (..load (_.code code))]
- (let [output ("lua apply" lua_function)]
- {try.#Success (if ("lua object nil?" output)
- []
- output)}))))]
- (: (Host _.Expression _.Statement)
- (implementation
- (def: (evaluate! context [_ code])
- (run! (_.return code)))
-
- (def: execute! run!)
-
- (def: (define! context custom [_ input])
- (let [global (maybe.else (reference.artifact context)
- custom)
- @global (_.var global)]
- (do try.monad
- [.let [definition (_.set (list @global) input)]
- _ (run! definition)
- value (run! (_.return @global))]
- (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! (_.return (_.var (reference.artifact context))))))))))))]))
+ (for @.old (as_is <jvm>)
+ @.jvm (as_is <jvm>)
+ @.lua (as_is (ffi.import: (load [ffi.String] "try" ffi.Function))
+ (def: host
+ (IO (Host _.Expression _.Statement))
+ (io (let [run! (: (-> _.Statement (Try Any))
+ (function (_ code)
+ (do try.monad
+ [lua_function (..load (_.code code))]
+ (let [output ("lua apply" lua_function)]
+ {try.#Success (if ("lua object nil?" output)
+ []
+ output)}))))]
+ (: (Host _.Expression _.Statement)
+ (implementation
+ (def: (evaluate! context [_ code])
+ (run! (_.return code)))
+
+ (def: execute! run!)
+
+ (def: (define! context custom [_ input])
+ (let [global (maybe.else (reference.artifact context)
+ custom)
+ @global (_.var global)]
+ (do try.monad
+ [.let [definition (_.set (list @global) input)]
+ _ (run! definition)
+ value (run! (_.return @global))]
+ (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! (_.return (_.var (reference.artifact context))))))))))))))
(with_expansions [<jvm> (as_is (def: (to_host it)
(-> Any java/lang/Object)
@@ -813,22 +813,22 @@
maybe.trusted
(:as java/lang/Object)
..read)))))]
- (for [@.old (as_is <jvm>)
- @.jvm (as_is <jvm>)
+ (for @.old (as_is <jvm>)
+ @.jvm (as_is <jvm>)
- @.lua
- (def: (extender phase_wrapper handler)
- (-> phase.Wrapper Extender)
- (:expected handler))]))
+ @.lua
+ (def: (extender phase_wrapper handler)
+ (-> phase.Wrapper Extender)
+ (:expected handler))))
(def: (phase_wrapper archive)
(-> Archive (runtime.Operation phase.Wrapper))
(do phase.monad
[]
(in (:as phase.Wrapper
- (for [@.old (..lua_function ..to_host)
- @.jvm (..lua_function ..to_host)
- @.lua (|>>)])))))
+ (for @.old (..lua_function ..to_host)
+ @.jvm (..lua_function ..to_host)
+ @.lua (|>>))))))
(with_expansions [<jvm> (def: platform
(IO [Baggage (Platform [Register _.Label] _.Expression _.Statement)])
@@ -841,18 +841,18 @@
platform.#runtime runtime.generate
platform.#phase_wrapper ..phase_wrapper
platform.#write (|>> _.code (# utf8.codec encoded))]])))]
- (for [@.old <jvm>
- @.jvm <jvm>
- @.lua (def: platform
- (IO (Platform [Register _.Label] _.Expression _.Statement))
- (do io.monad
- [host ..host]
- (in [platform.#&file_system (file.async file.default)
- platform.#host host
- platform.#phase lua.generate
- platform.#runtime runtime.generate
- platform.#phase_wrapper ..phase_wrapper
- platform.#write (|>> _.code (# utf8.codec encoded))])))]))
+ (for @.old <jvm>
+ @.jvm <jvm>
+ @.lua (def: platform
+ (IO (Platform [Register _.Label] _.Expression _.Statement))
+ (do io.monad
+ [host ..host]
+ (in [platform.#&file_system (file.async file.default)
+ platform.#host host
+ platform.#phase lua.generate
+ platform.#runtime runtime.generate
+ platform.#phase_wrapper ..phase_wrapper
+ platform.#write (|>> _.code (# utf8.codec encoded))])))))
(def: (program context program)
(Program _.Expression _.Statement)
@@ -872,16 +872,16 @@
(`` (program: [service cli.service]
(let [context (context.lua (cli.target service))]
(do io.monad
- [(~~ (for [@.old [baggage platform]
- @.jvm [baggage platform]
- @.lua platform]))
+ [(~~ (for @.old [baggage platform]
+ @.jvm [baggage platform]
+ @.lua platform))
..platform]
(exec (do async.monad
[_ (/.compiler ..lux_compiler
context
- (for [@.old (..expander ..to_host baggage)
- @.jvm (..expander ..to_host baggage)
- @.lua ..expander])
+ (for @.old (..expander ..to_host baggage)
+ @.jvm (..expander ..to_host baggage)
+ @.lua ..expander)
analysis.bundle
(io.io platform)
generation.bundle
@@ -890,9 +890,9 @@
[(type [Register _.Label])
_.Expression
_.Statement]
- (for [@.old (..extender baggage)
- @.jvm (..extender baggage)
- @.lua ..extender])
+ (for @.old (..extender baggage)
+ @.jvm (..extender baggage)
+ @.lua ..extender)
service
[(packager.package (_.manual "")
_.code