aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--documentation/bookmark/business/negotiation.md4
-rw-r--r--documentation/bookmark/data_structure/probabilistic.md (renamed from documentation/bookmark/probabilistic_data_structure.md)1
-rw-r--r--documentation/bookmark/database.md4
-rw-r--r--documentation/bookmark/tool/insight.md4
-rw-r--r--documentation/bookmark/transducer_stream_pipe.md51
-rw-r--r--lux-lua/commands.md4
-rw-r--r--lux-lua/source/program.lux465
-rw-r--r--stdlib/source/library/lux/ffi.jvm.lux1
-rw-r--r--stdlib/source/library/lux/tool/compiler/default/platform.lux21
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux81
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux81
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux3
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux3
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux3
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux1
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux23
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux42
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux58
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux92
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/synthesis/simple.lux70
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/archive/unit.lux8
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/cache/dependency/artifact.lux2
-rw-r--r--stdlib/source/test/lux/data/text.lux3
-rw-r--r--stdlib/source/test/lux/extension.lux6
-rw-r--r--stdlib/source/test/lux/ffi.jvm.lux60
-rw-r--r--stdlib/source/test/lux/tool.lux3
-rw-r--r--stdlib/source/test/lux/tool/compiler/language/lux/synthesis/simple.lux45
29 files changed, 664 insertions, 479 deletions
diff --git a/documentation/bookmark/business/negotiation.md b/documentation/bookmark/business/negotiation.md
new file mode 100644
index 000000000..636bcbbfe
--- /dev/null
+++ b/documentation/bookmark/business/negotiation.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Rethinking Negotiation: A smarter way to split the pie](https://hbr.org/2021/11/rethinking-negotiation)
+
diff --git a/documentation/bookmark/probabilistic_data_structure.md b/documentation/bookmark/data_structure/probabilistic.md
index 32f31bf24..5831523c6 100644
--- a/documentation/bookmark/probabilistic_data_structure.md
+++ b/documentation/bookmark/data_structure/probabilistic.md
@@ -5,6 +5,7 @@
# Reference
+0. [Ribbon Filter](http://rocksdb.org/blog/2021/12/29/ribbon-filter.html)
0. [Binary Fuse Filters: Fast and Smaller Than Xor Filters](https://arxiv.org/abs/2201.01174)
0. [Ribbon filter: practically smaller than Bloom and Xor](https://arxiv.org/abs/2103.02515)
0. [Xor Filters: Faster and Smaller Than Bloom Filters](https://lemire.me/blog/2019/12/19/xor-filters-faster-and-smaller-than-bloom-filters/)
diff --git a/documentation/bookmark/database.md b/documentation/bookmark/database.md
index f061b7604..b2fb5591e 100644
--- a/documentation/bookmark/database.md
+++ b/documentation/bookmark/database.md
@@ -186,6 +186,10 @@
0. https://www.aerospike.com/
0. https://sirix.io/
+## Relational
+
+0. [dqlite: Embeddable, replicated and fault tolerant SQL engine.](https://github.com/canonical/dqlite)
+
## Immutable
0. [immudb: OPEN SOURCE IMMUTABLE DATABASE](https://codenotary.com/technologies/immudb/)
diff --git a/documentation/bookmark/tool/insight.md b/documentation/bookmark/tool/insight.md
new file mode 100644
index 000000000..614f41b5c
--- /dev/null
+++ b/documentation/bookmark/tool/insight.md
@@ -0,0 +1,4 @@
+# Exemplar
+
+0. [C++ Insights - See your source code with the eyes of a compiler.](https://github.com/andreasfertig/cppinsights)
+
diff --git a/documentation/bookmark/transducer_stream_pipe.md b/documentation/bookmark/transducer_stream_pipe.md
index 5ba3f040a..cb8aae481 100644
--- a/documentation/bookmark/transducer_stream_pipe.md
+++ b/documentation/bookmark/transducer_stream_pipe.md
@@ -1,28 +1,29 @@
# Reference
-1. [zug](https://sinusoid.es/zug/)
-1. https://dev.to/greencoder/build-your-own-transducer-and-impress-your-cat---part-1-mhp
-1. https://functional.works-hub.com/learn/reducers-and-transducers-introductory-d0cff
-1. http://beerendlauwers.be/posts/2015-12-09-transducers.html
-1. https://clojure.org/reference/transducers
-1. http://sickaf.xyz/2017/07/transducers
-1. http://hypirion.com/musings/haskell-transducers
-1. https://github.com/hyPiRion/haskell-transducers
-1. https://github.com/cgrand/xforms
-1. https://deque.blog/2017/07/28/implementing-clojure-like-transducers-in-idris-part-1/
-1. http://jlongster.com/Transducers.js--A-JavaScript-Library-for-Transformation-of-Data
-1. https://labs.uswitch.com/transducers-from-the-ground-up-the-essence/amp/
-1. https://bendyworks.com/blog/transducers-clojures-next-big-idea
-1. http://conscientiousprogrammer.com/blog/2014/08/07/understanding-cloure-transducers-through-types/
-1. [Lighting Talk - How to Write a Fast, Reducible Collection - Ghadi Shayban](https://www.youtube.com/watch?v=FjKnlzQfAPc)
-1. [Lazy v. Yield: Incremental, Linear Pretty-printing](https://www.cs.indiana.edu/~sabry/papers/yield-pp.pdf)
-1. https://labs.uswitch.com/transducers-from-the-ground-up-the-practice/
-1. [Continuations and Transducer Composition](http://matt.might.net/papers/might2006transducers.pdf)
-1. https://deque.blog/2017/11/13/free-monads-from-basics-up-to-implementing-composable-and-effectful-stream-processing/
-1. https://www.tweag.io/posts/2018-06-21-linear-streams.html
-1. [Common Lisp Study Group An Intro to SERIES](https://www.youtube.com/watch?v=uRLgZCV4bOM)
-1. [Appendix A. Series](https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node347.html)
-1. [YOW! Lambda Jam 2018 - Simon Belak - Transducing for fun and profit](https://www.youtube.com/watch?v=H0sSbTWxTsM)
-1. https://nextjournal.com/zampino/fold
-1. [Fusing Effectful Comprehensions*](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/10/fusing_effectful_comprehensions.pdf)
+0. [Complete Guide to Transducers](https://nwcalvank.dev/transducers/)
+0. [zug](https://sinusoid.es/zug/)
+0. https://dev.to/greencoder/build-your-own-transducer-and-impress-your-cat---part-1-mhp
+0. https://functional.works-hub.com/learn/reducers-and-transducers-introductory-d0cff
+0. http://beerendlauwers.be/posts/2015-12-09-transducers.html
+0. https://clojure.org/reference/transducers
+0. http://sickaf.xyz/2017/07/transducers
+0. http://hypirion.com/musings/haskell-transducers
+0. https://github.com/hyPiRion/haskell-transducers
+0. https://github.com/cgrand/xforms
+0. https://deque.blog/2017/07/28/implementing-clojure-like-transducers-in-idris-part-1/
+0. http://jlongster.com/Transducers.js--A-JavaScript-Library-for-Transformation-of-Data
+0. https://labs.uswitch.com/transducers-from-the-ground-up-the-essence/amp/
+0. https://bendyworks.com/blog/transducers-clojures-next-big-idea
+0. http://conscientiousprogrammer.com/blog/2014/08/07/understanding-cloure-transducers-through-types/
+0. [Lighting Talk - How to Write a Fast, Reducible Collection - Ghadi Shayban](https://www.youtube.com/watch?v=FjKnlzQfAPc)
+0. [Lazy v. Yield: Incremental, Linear Pretty-printing](https://www.cs.indiana.edu/~sabry/papers/yield-pp.pdf)
+0. https://labs.uswitch.com/transducers-from-the-ground-up-the-practice/
+0. [Continuations and Transducer Composition](http://matt.might.net/papers/might2006transducers.pdf)
+0. https://deque.blog/2017/11/13/free-monads-from-basics-up-to-implementing-composable-and-effectful-stream-processing/
+0. https://www.tweag.io/posts/2018-06-21-linear-streams.html
+0. [Common Lisp Study Group An Intro to SERIES](https://www.youtube.com/watch?v=uRLgZCV4bOM)
+0. [Appendix A. Series](https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node347.html)
+0. [YOW! Lambda Jam 2018 - Simon Belak - Transducing for fun and profit](https://www.youtube.com/watch?v=H0sSbTWxTsM)
+0. https://nextjournal.com/zampino/fold
+0. [Fusing Effectful Comprehensions*](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/10/fusing_effectful_comprehensions.pdf)
diff --git a/lux-lua/commands.md b/lux-lua/commands.md
index 6ba400775..08fb948a1 100644
--- a/lux-lua/commands.md
+++ b/lux-lua/commands.md
@@ -11,8 +11,8 @@ cd ~/lux/lux-lua/ && lein clean && lein lux auto test
## Develop
## NOTE: Must set lux/control/concurrency/thread.parallelism = 1 before compiling to make sure Rembulan doesn't cause trouble.
cd ~/lux/lux-lua/ \
-&& lein clean \
-&& lein lux auto build
+&& lux clean \
+&& lux auto build
```
# Try
diff --git a/lux-lua/source/program.lux b/lux-lua/source/program.lux
index 2f5fdb67e..f1a759f2d 100644
--- a/lux-lua/source/program.lux
+++ b/lux-lua/source/program.lux
@@ -3,6 +3,7 @@
[lux "*"
[program {"+" program:}]
["[0]" ffi]
+ ["[0]" static]
[abstract
["[0]" monad {"+" do}]]
[control
@@ -20,9 +21,10 @@
["[0]" utf8]]]
[collection
["[0]" array {"+" Array}]
- ["[0]" list]]]
+ ["[0]" list ("[1]#[0]" monad)]]]
[macro
- ["[0]" template]]
+ ["[0]" template]
+ ["[0]" code]]
[math
[number {"+" hex}
["n" nat]
@@ -33,7 +35,7 @@
["@" target
["_" lua]]
[tool
- [compiler
+ ["[0]" compiler
["[0]" phase {"+" Operation Phase}]
[reference
[variable {"+" Register}]]
@@ -58,12 +60,12 @@
["[0]" platform {"+" Platform}]]
[meta
["[0]" cli]
+ ["[0]" context]
[archive {"+" Archive}]
["[0]" packager "_"
["[1]" script]]]]]]]
[program
- ["/" compositor
- ["[1][0]" static]]])
+ ["/" compositor]])
(with_expansions [<jvm> (as_is (ffi.import: java/lang/String)
@@ -74,9 +76,11 @@
(toString [] java/lang/String)
(getClass [] (java/lang/Class java/lang/Object))])
+ (ffi.import: java/lang/Integer)
+
(ffi.import: java/lang/Long
["[1]::[0]"
- (intValue [] java/lang/Integer)])
+ (intValue [] int)])
(ffi.import: net/sandius/rembulan/StateContext)
@@ -126,6 +130,7 @@
["[1]::[0]"
(getReturnBuffer [] net/sandius/rembulan/runtime/ReturnBuffer)])
+ (ffi.import: net/sandius/rembulan/runtime/ResolvedControlThrowable)
(ffi.import: net/sandius/rembulan/runtime/LuaFunction)
(ffi.import: net/sandius/rembulan/load/ChunkLoader
@@ -151,76 +156,15 @@
(exception: (unknown_kind_of_object [object java/lang/Object])
(exception.report
- ["Class" (java/lang/Object::toString (java/lang/Object::getClass object))]
- ["Object" (java/lang/Object::toString object)]))
-
- (template [<name>]
- [(ffi.interface: <name>
- (getValue [] java/lang/Object))
-
- (`` (ffi.import: (~~ (template.symbol ["program/" <name>]))
- ["[1]::[0]"
- (getValue [] java/lang/Object)]))]
-
- [StructureValue]
- )
-
- (def: (lux_structure value)
- (-> (Array java/lang/Object) program/StructureValue)
- (let [re_wrap (: (-> java/lang/Object java/lang/Object)
- (function (_ unwrapped)
- (case (ffi.check [java/lang/Object] unwrapped)
- {.#Some sub_value}
- (|> sub_value (:as (Array java/lang/Object)) lux_structure (:as java/lang/Object))
-
- {.#None}
- unwrapped)))]
- (:as program/StructureValue
- (ffi.object [] net/sandius/rembulan/impl/DefaultTable [program/StructureValue]
- []
- ... Methods
- (program/StructureValue
- [] (getValue self []) java/lang/Object
- (:as java/lang/Object value))
-
- (net/sandius/rembulan/impl/DefaultTable
- [] (rawlen self []) long
- (|> value array.size (:as java/lang/Long)))
-
- (net/sandius/rembulan/impl/DefaultTable
- [] (rawget self [idx long]) java/lang/Object
- (|> value (array.read! (|> idx (:as Nat) --)) maybe.trusted re_wrap))
-
- (net/sandius/rembulan/impl/DefaultTable
- [] (rawget self [field java/lang/Object]) java/lang/Object
- (case (ffi.check net/sandius/rembulan/ByteString field)
- {.#Some field}
- (case (net/sandius/rembulan/ByteString::decode field)
- (^ (static runtime.variant_tag_field))
- (|> value (array.read! 0) maybe.trusted)
-
- (^ (static runtime.variant_flag_field))
- (case (array.read! 1 value)
- {.#Some _}
- (:as java/lang/Object "")
-
- {.#None}
- (ffi.null))
-
- (^ (static runtime.variant_value_field))
- (|> value (array.read! 2) maybe.trusted re_wrap)
+ ["Class" (ffi.of_string (java/lang/Object::toString (java/lang/Object::getClass object)))]
+ ["Object" (ffi.of_string (java/lang/Object::toString object))]))
- _
- (panic! (exception.error ..unknown_kind_of_object [(:as java/lang/Object field)])))
+ (ffi.interface: LuxValue
+ (getValue [] java/lang/Object))
- {.#None}
- (case (ffi.check java/lang/Long field)
- {.#Some idx}
- (|> value (array.read! (|> idx (:as Nat) --)) maybe.trusted re_wrap)
-
- {.#None}
- (panic! (exception.error ..unknown_kind_of_object [(:as java/lang/Object field)])))))
- ))))
+ (ffi.import: LuxValue
+ ["[1]::[0]"
+ (getValue [] java/lang/Object)])
(type: Translator
(-> java/lang/Object (Try Any)))
@@ -233,7 +177,11 @@
(^multi [{.#Some tag} ?flag {.#Some value}]
[(read value)
{try.#Success value}])
- {try.#Success [(: Any (|> tag (:as java/lang/Long) java/lang/Long::intValue))
+ {try.#Success [(: Any (|> tag
+ (:as Int)
+ ffi.as_long
+ java/lang/Long::intValue
+ (: java/lang/Integer)))
(: Any (case ?flag
{.#Some _} (: Any "")
{.#None} (:as Any (ffi.null))))
@@ -244,13 +192,13 @@
(def: (read_tuple read host_object)
(-> Translator net/sandius/rembulan/impl/DefaultTable (Try Any))
- (let [init_num_keys (.nat (net/sandius/rembulan/Table::rawlen host_object))]
+ (let [init_num_keys (.nat (ffi.of_long (net/sandius/rembulan/Table::rawlen host_object)))]
(loop [num_keys init_num_keys
idx 0
output (: (Array java/lang/Object)
(array.empty init_num_keys))]
(if (n.< num_keys idx)
- (case (net/sandius/rembulan/Table::get_idx (:as java/lang/Long (++ idx)) host_object)
+ (case (net/sandius/rembulan/Table::get_idx (ffi.as_long (.int (++ idx))) host_object)
{.#None}
(again num_keys (++ idx) output)
@@ -276,50 +224,237 @@
_)]
+ [LuxValue (<| {try.#Success} LuxValue::getValue)]
[java/lang/Boolean {try.#Success}]
[java/lang/Long {try.#Success}]
[java/lang/Double {try.#Success}]
[java/lang/String {try.#Success}]
- [net/sandius/rembulan/runtime/LuaFunction {try.#Success}]
[net/sandius/rembulan/ByteString (<| {try.#Success} net/sandius/rembulan/ByteString::decode)]
- [program/StructureValue (<| {try.#Success} program/StructureValue::getValue)]
+ [net/sandius/rembulan/runtime/LuaFunction {try.#Success}]
))
(case (ffi.check net/sandius/rembulan/impl/DefaultTable host_object)
{.#Some typed_object}
(case (read_variant read typed_object)
- {try.#Success value}
- {try.#Success value}
-
{try.#Failure error}
- (read_tuple read typed_object))
+ (read_tuple read typed_object)
+
+ success
+ success)
_)
(exception.except ..unknown_kind_of_object [host_object])
)))
+ (def: (return ec value)
+ (-> net/sandius/rembulan/runtime/ExecutionContext Any Any)
+ (|> ec
+ net/sandius/rembulan/runtime/ExecutionContext::getReturnBuffer
+ (net/sandius/rembulan/runtime/ReturnBuffer::setTo (:as java/lang/Object value))))
+
+ (def: (function/* arity)
+ (-> Nat Code)
+ (` (.-> (~+ (list.repeated arity (` .Any)))
+ .Any)))
+
+ (def: input/*
+ (-> Nat (List Code))
+ (|>> list.indices
+ (list#each (|>> %.nat (format "input/") code.local_symbol))))
+
+ (def: declaration/*
+ (-> Nat (List Code))
+ (|>> ..input/*
+ (list#each (function (_ $input)
+ (list $input (' java/lang/Object))))
+ list#conjoint))
+
+ (def: read/*
+ (-> Nat (List Code))
+ (|>> ..input/*
+ (list#each (function (_ $input)
+ (list $input (` (..read (~ $input))))))
+ list#conjoint))
+
+ (def: (apply/* to_host self parameters abstraction)
+ (-> (-> Any java/lang/Object) net/sandius/rembulan/runtime/LuaFunction (List java/lang/Object) Any Any)
+ (<| try.trusted
+ (do [! try.monad]
+ [input/* (monad.each ! ..read parameters)]
+ (loop [lux_function abstraction
+ input/* input/*]
+ (`` (`` (case input/*
+ (^ (list))
+ (in self)
+
+ (~~ (template [<arity>]
+ [(^ (list (~~ (static.literals function.identity (..input/* <arity>)))))
+ (in (to_host ((:as (~~ (static.literal function.identity (..function/* <arity>)))
+ lux_function)
+ (~~ (static.literals function.identity (..input/* <arity>))))))]
+
+ [1]
+ [2]
+ [3]
+ [4]
+ [5]
+ ))
+
+ (^ (list& (~~ (static.literals function.identity (..input/* 5))) input/+))
+ (again ((:as (~~ (static.literal function.identity (..function/* 5)))
+ lux_function)
+ (~~ (static.literals function.identity (..input/* 5))))
+ input/+)
+ )))))))
+
+ (def: (lua_function to_host lux_function)
+ (-> (-> Any java/lang/Object) Any net/sandius/rembulan/runtime/LuaFunction)
+ (<| (:as net/sandius/rembulan/runtime/LuaFunction)
+ (`` (`` (ffi.object [] net/sandius/rembulan/runtime/LuaFunction [LuxValue]
+ []
+ ... Methods
+ (LuxValue
+ [] (getValue self []) java/lang/Object
+ (:as java/lang/Object lux_function))
+
+ (net/sandius/rembulan/runtime/LuaFunction
+ [] (invoke self [% net/sandius/rembulan/runtime/ExecutionContext])
+ void
+ "throws" [net/sandius/rembulan/runtime/ResolvedControlThrowable]
+ (<| (..return %)
+ self))
+
+ (~~ (template [<arity>]
+ [(net/sandius/rembulan/runtime/LuaFunction
+ [] (invoke self [% net/sandius/rembulan/runtime/ExecutionContext
+ (~~ (static.literals function.identity (..declaration/* <arity>)))])
+ void
+ "throws" [net/sandius/rembulan/runtime/ResolvedControlThrowable]
+ (<| (..return %)
+ (apply/* to_host
+ (ffi.:as net/sandius/rembulan/runtime/LuaFunction self)
+ (list (~~ (static.literals function.identity (..input/* <arity>))))
+ lux_function)))]
+
+ [1]
+ [2]
+ [3]
+ [4]
+ [5]
+ ))
+
+ (net/sandius/rembulan/runtime/LuaFunction
+ [] (invoke self [% net/sandius/rembulan/runtime/ExecutionContext
+ input/* [java/lang/Object]])
+ void
+ "throws" [net/sandius/rembulan/runtime/ResolvedControlThrowable]
+ (<| (..return %)
+ (apply/* to_host
+ (ffi.:as net/sandius/rembulan/runtime/LuaFunction self)
+ (array.list {.#None} input/*)
+ lux_function)))
+ )))))
+
+ (ffi.import: library/lux/Function)
+
+ (def: (lux_structure to_host value)
+ (-> (-> Any java/lang/Object) (Array java/lang/Object) LuxValue)
+ (<| (ffi.:as LuxValue)
+ (ffi.object [] net/sandius/rembulan/impl/DefaultTable [LuxValue]
+ []
+ ... Methods
+ (LuxValue
+ [] (getValue self []) java/lang/Object
+ (:as java/lang/Object value))
+
+ (net/sandius/rembulan/impl/DefaultTable
+ [] (rawlen self []) long
+ (|> value array.size .int ffi.as_long))
+
+ (net/sandius/rembulan/impl/DefaultTable
+ [] (rawget self [idx long]) java/lang/Object
+ (|> value
+ (array.read! (|> idx ffi.of_long .nat --))
+ maybe.trusted
+ to_host))
+
+ (net/sandius/rembulan/impl/DefaultTable
+ [] (rawget self [field java/lang/Object])
+ java/lang/Object
+ (case (ffi.check net/sandius/rembulan/ByteString field)
+ {.#Some field}
+ (case (ffi.of_string (net/sandius/rembulan/ByteString::decode field))
+ (^ (static runtime.variant_tag_field))
+ (case (array.read! 0 value)
+ {.#Some it}
+ (|> it
+ (:as java/lang/Integer)
+ (ffi.:as java/lang/Object))
+
+ {.#None}
+ (undefined))
+
+ (^ (static runtime.variant_flag_field))
+ (case (array.read! 1 value)
+ {.#Some _}
+ (:as java/lang/Object "")
+
+ {.#None}
+ (ffi.null))
+
+ (^ (static runtime.variant_value_field))
+ (|> value
+ (array.read! 2)
+ maybe.trusted
+ to_host)
+
+ "n"
+ (|> value
+ array.size
+ .int
+ ffi.as_long
+ (ffi.:as java/lang/Object))
+
+ _
+ (panic! (exception.error ..unknown_kind_of_object [(:as java/lang/Object field)])))
+
+ {.#None}
+ (case (ffi.check java/lang/Long field)
+ {.#Some idx}
+ (case (array.read! (|> idx ffi.of_long .nat --) value)
+ {.#Some it}
+ (to_host it)
+
+ {.#None}
+ (: java/lang/Object (ffi.null)))
+
+ {.#None}
+ (panic! (exception.error ..unknown_kind_of_object [(:as java/lang/Object field)])))))
+ )))
+
(exception: (cannot_apply_a_non_function [object java/lang/Object])
(exception.report
- ["Non-function" (java/lang/Object::toString object)]))
+ ["Non-function" (ffi.of_string (java/lang/Object::toString object))]))
(def: ensure_function
(-> Macro (Maybe net/sandius/rembulan/runtime/LuaFunction))
- (|>> (:as java/lang/Object) (ffi.check net/sandius/rembulan/runtime/LuaFunction)))
+ (|>> (:as java/lang/Object)
+ (ffi.check net/sandius/rembulan/runtime/LuaFunction)))
(type: Baggage
[net/sandius/rembulan/StateContext
net/sandius/rembulan/exec/DirectCallExecutor])
- (def: (call_macro [state_context executor] inputs lux macro)
- (-> Baggage (List Code) Lux net/sandius/rembulan/runtime/LuaFunction (Try Any))
+ (def: (call_macro to_host [state_context executor] inputs lux macro)
+ (-> (-> Any java/lang/Object) Baggage (List Code) Lux net/sandius/rembulan/runtime/LuaFunction (Try Any))
(do try.monad
[.let [inputs (: (ffi.type [java/lang/Object])
(|> (array.empty 2)
(array.write! 0 ... (:as java/lang/Object inputs)
... (net/sandius/rembulan/impl/ImmutableTable$Builder::build (net/sandius/rembulan/impl/ImmutableTable$Builder::new))
- (:as java/lang/Object (lux_structure (:as (Array java/lang/Object) inputs))))
+ (:as java/lang/Object (lux_structure to_host (:as (Array java/lang/Object) inputs))))
(array.write! 1 ... (:as java/lang/Object lux)
... (net/sandius/rembulan/impl/ImmutableTable$Builder::build (net/sandius/rembulan/impl/ImmutableTable$Builder::new))
- (:as java/lang/Object (lux_structure (:as (Array java/lang/Object) lux))))))]
+ (:as java/lang/Object (lux_structure to_host (:as (Array java/lang/Object) lux))))))]
output (net/sandius/rembulan/exec/DirectCallExecutor::call state_context (:as java/lang/Object macro) inputs executor)]
(|> output
(array.read! 0)
@@ -327,11 +462,11 @@
(:as java/lang/Object)
..read)))
- (def: (expander baggage macro inputs lux)
- (-> Baggage Expander)
+ (def: (expander to_host baggage macro inputs lux)
+ (-> (-> Any java/lang/Object) Baggage Expander)
(case (..ensure_function macro)
{.#Some macro}
- (case (..call_macro baggage inputs lux macro)
+ (case (..call_macro to_host baggage inputs lux macro)
{try.#Success output}
(|> output
(:as (Try [Lux (List Code)]))
@@ -545,13 +680,13 @@
state_context (net/sandius/rembulan/impl/StateContexts::newDefaultInstance)
table (net/sandius/rembulan/lib/StandardLibrary::installInto state_context std_lib)
variable (net/sandius/rembulan/Variable::new table)
- loader (net/sandius/rembulan/compiler/CompilerChunkLoader::of "_lux_definition")
+ loader (net/sandius/rembulan/compiler/CompilerChunkLoader::of (ffi.as_string "_lux_definition"))
executor (net/sandius/rembulan/exec/DirectCallExecutor::newExecutor)
scheduling_context (net/sandius/rembulan/exec/DirectCallExecutor::schedulingContextFactory executor)
run! (: (-> _.Statement (Try Any))
(function (_ code)
(do try.monad
- [lua_function (net/sandius/rembulan/load/ChunkLoader::loadTextChunk variable "lux compilation" (_.code code) loader)
+ [lua_function (net/sandius/rembulan/load/ChunkLoader::loadTextChunk variable (ffi.as_string "lux compilation") (ffi.as_string (_.code code)) loader)
output (net/sandius/rembulan/exec/DirectCallExecutor::call state_context (:as java/lang/Object lua_function) (array.empty 0)
executor)]
(case (array.read! 0 output)
@@ -564,23 +699,26 @@
[[state_context executor]
(: (Host _.Expression _.Statement)
(implementation
- (def: (evaluate context code)
+ (def: (evaluate context [_ code])
(run! (_.return code)))
(def: execute run!)
- (def: (define context custom input)
+ (def: (define context custom [_ input])
(let [global (maybe.else (reference.artifact context)
custom)
- @global (_.var global)]
+ @global (_.var global)
+ definition (_.set (list @global) input)]
(do try.monad
- [.let [definition (_.set (list @global) input)]
- _ (run! definition)
+ [_ (run! definition)
value (run! (_.return @global))]
(in [global value definition]))))
(def: (ingest context content)
- (|> content (# utf8.codec decoded) try.trusted (:as _.Statement)))
+ (|> content
+ (# utf8.codec decoded)
+ try.trusted
+ (:as _.Statement)))
(def: (re_learn context custom content)
(run! content))
@@ -604,12 +742,12 @@
output)}))))]
(: (Host _.Expression _.Statement)
(implementation
- (def: (evaluate! context code)
+ (def: (evaluate! context [_ code])
(run! (_.return code)))
(def: execute! run!)
- (def: (define! context custom input)
+ (def: (define! context custom [_ input])
(let [global (maybe.else (reference.artifact context)
custom)
@global (_.var global)]
@@ -630,103 +768,20 @@
[_ (run! content)]
(run! (_.return (_.var (reference.artifact context))))))))))))]))
-(with_expansions [<jvm> (as_is (exception: .public (invaid_phase_application [partial_application (List Any)
- arity Nat])
- (exception.report
- ["Partial Application" (%.nat (list.size partial_application))]
- ["Arity" (%.nat arity)]))
-
- (def: to_host
+(with_expansions [<jvm> (as_is (def: (to_host it)
(-> Any java/lang/Object)
- (|>> (:as (Array java/lang/Object)) ..lux_structure (:as java/lang/Object)))
-
- (def: (return ec value)
- (-> net/sandius/rembulan/runtime/ExecutionContext Any Any)
- (|> ec
- net/sandius/rembulan/runtime/ExecutionContext::getReturnBuffer
- (net/sandius/rembulan/runtime/ReturnBuffer::setTo (:as java/lang/Object value))))
-
- (def: (host_phase partial_application phase)
- (All (_ s i o)
- (-> (List Any) (Phase [extension.Bundle s] i o)
- java/lang/Object))
- (ffi.object [] net/sandius/rembulan/runtime/LuaFunction []
- []
- ... Methods
- (net/sandius/rembulan/runtime/LuaFunction
- [] (invoke self [% net/sandius/rembulan/runtime/ExecutionContext])
- void
- (<| (..return %)
- (host_phase partial_application phase)))
-
- (net/sandius/rembulan/runtime/LuaFunction
- [] (invoke self [% net/sandius/rembulan/runtime/ExecutionContext
- input/0 java/lang/Object])
- void
- (<| (..return %)
- try.trusted
- (do try.monad
- [input/0 (..read input/0)]
- (case partial_application
- (^ (list partial/0 partial/1))
- (in (..to_host ((:as (-> Any Any Any Any) phase)
- partial/0
- partial/1
- input/0)))
-
- (^ (list partial/0))
- (in (host_phase (list partial/0 input/0) phase))
-
- (^ (list))
- (in (host_phase (list input/0) phase))
+ (`` (<| (~~ (template [<jvm> <lua>]
+ [(case (ffi.check <jvm> (:as java/lang/Object it))
+ {.#Some it}
+ (:as java/lang/Object
+ (<lua> [(:expected it)]))
- _
- (exception.except ..invaid_phase_application [partial_application 2])))))
-
- (net/sandius/rembulan/runtime/LuaFunction
- [] (invoke self [% net/sandius/rembulan/runtime/ExecutionContext
- input/0 java/lang/Object
- input/1 java/lang/Object])
- void
- (<| (..return %)
- try.trusted
- (do try.monad
- [input/0 (..read input/0)
- input/1 (..read input/1)]
- (case partial_application
- (^ (list partial/0))
- (in (..to_host ((:as (-> Any Any Any Any) phase)
- partial/0
- input/0
- input/1)))
-
- (^ (list))
- (in (host_phase (list input/0 input/1) phase))
+ {.#None})]
- _
- (exception.except ..invaid_phase_application [partial_application 2])))))
-
- (net/sandius/rembulan/runtime/LuaFunction
- [] (invoke self [% net/sandius/rembulan/runtime/ExecutionContext
- input/0 java/lang/Object
- input/1 java/lang/Object
- input/2 java/lang/Object])
- void
- (<| (..return %)
- try.trusted
- (do try.monad
- [input/0 (..read input/0)
- input/1 (..read input/1)
- input/2 (..read input/2)]
- (case partial_application
- (^ (list))
- (in (..to_host ((:as (-> Any Any Any Any) phase)
- input/0
- input/1
- input/2)))
-
- _
- (exception.except ..invaid_phase_application [partial_application 3])))))))
+ [[java/lang/Object] (..lux_structure to_host)]
+ [library/lux/Function (..lua_function to_host)]
+ ))
+ (:as java/lang/Object it))))
(def: (extender [state_context executor] phase_wrapper)
(-> Baggage (-> phase.Wrapper Extender))
@@ -771,8 +826,8 @@
(do phase.monad
[]
(in (:as phase.Wrapper
- (for [@.old (..host_phase (list))
- @.jvm (..host_phase (list))
+ (for [@.old (..lua_function ..to_host)
+ @.jvm (..lua_function ..to_host)
@.lua (|>>)])))))
(with_expansions [<jvm> (def: platform
@@ -810,6 +865,10 @@
(-> Any (Async Any))
(async.future (# world/program.default exit +0)))
+(def: (lux_compiler it)
+ (-> Any compiler.Custom)
+ (undefined))
+
(`` (program: [service cli.service]
(let [extension ".lua"]
(do io.monad
@@ -818,12 +877,10 @@
@.lua platform]))
..platform]
(exec (do async.monad
- [_ (/.compiler [/static.#host @.lua
- /static.#host_module_extension extension
- /static.#target (cli.target service)
- /static.#artifact_extension extension]
- (for [@.old (..expander baggage)
- @.jvm (..expander baggage)
+ [_ (/.compiler ..lux_compiler
+ (context.lua (cli.target service))
+ (for [@.old (..expander ..to_host baggage)
+ @.jvm (..expander ..to_host baggage)
@.lua ..expander])
analysis.bundle
(io.io platform)
diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux
index ff3550fde..b43a1b122 100644
--- a/stdlib/source/library/lux/ffi.jvm.lux
+++ b/stdlib/source/library/lux/ffi.jvm.lux
@@ -1956,5 +1956,6 @@
[as_byte .Int ..long_to_byte ..Long ..byte_to_long ..Byte of_byte]
[as_short .Int ..long_to_short ..Long ..short_to_long ..Short of_short]
[as_int .Int ..long_to_int ..Long ..int_to_long ..Integer of_int]
+ [as_char .Int ..long_to_char ..Long ..char_to_long ..Character of_char]
[as_float .Frac ..double_to_float ..Double ..float_to_double ..Float of_float]
)
diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux
index 752d3fe65..c63f5cb2c 100644
--- a/stdlib/source/library/lux/tool/compiler/default/platform.lux
+++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux
@@ -577,16 +577,17 @@
///directive.#analysis
///directive.#state
extension.#state]
- (function (_ analysis_state)
- (|> analysis_state
- (:as .Lux)
- (revised@ .#modules (function (_ current)
- (list#composite (list.only (|>> product.left
- (set.member? additions)
- not)
- current)
- modules)))
- :expected))))]
+ (: (All (_ a) (-> a a))
+ (function (_ analysis_state)
+ (|> analysis_state
+ (:as .Lux)
+ (revised@ .#modules (function (_ current)
+ (list#composite (list.only (|>> product.left
+ (set.member? additions)
+ not)
+ current)
+ modules)))
+ :expected)))))]
state (monad.mix ! with_all_extensions state extended_states)]
(in (with_modules state))))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux
index 7e286955e..f6e024d3b 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux
@@ -43,68 +43,73 @@
(custom
[<code>.any
(function (_ extension phase archive lengthC)
- (do phase.monad
- [lengthA (analysis/type.expecting Nat
- (phase archive lengthC))
- [var_id varT] (analysis/type.check check.var)
- _ (analysis/type.inference (type (Array varT)))]
- (in {analysis.#Extension extension (list lengthA)})))]))
+ (<| analysis/type.with_var
+ (function (_ [@var :var:]))
+ (do phase.monad
+ [lengthA (analysis/type.expecting Nat
+ (phase archive lengthC))
+ _ (analysis/type.inference (type (Array :var:)))]
+ (in {analysis.#Extension extension (list lengthA)}))))]))
(def: array::length
Handler
(custom
[<code>.any
(function (_ extension phase archive arrayC)
- (do phase.monad
- [[var_id varT] (analysis/type.check check.var)
- arrayA (analysis/type.expecting (type (Array varT))
- (phase archive arrayC))
- _ (analysis/type.inference Nat)]
- (in {analysis.#Extension extension (list arrayA)})))]))
+ (<| analysis/type.with_var
+ (function (_ [@var :var:]))
+ (do phase.monad
+ [arrayA (analysis/type.expecting (type (Array :var:))
+ (phase archive arrayC))
+ _ (analysis/type.inference Nat)]
+ (in {analysis.#Extension extension (list arrayA)}))))]))
(def: array::read
Handler
(custom
[(<>.and <code>.any <code>.any)
(function (_ extension phase archive [indexC arrayC])
- (do phase.monad
- [indexA (analysis/type.expecting Nat
- (phase archive indexC))
- [var_id varT] (analysis/type.check check.var)
- arrayA (analysis/type.expecting (type (Array varT))
- (phase archive arrayC))
- _ (analysis/type.inference varT)]
- (in {analysis.#Extension extension (list indexA arrayA)})))]))
+ (<| analysis/type.with_var
+ (function (_ [@var :var:]))
+ (do phase.monad
+ [indexA (analysis/type.expecting Nat
+ (phase archive indexC))
+ arrayA (analysis/type.expecting (type (Array :var:))
+ (phase archive arrayC))
+ _ (analysis/type.inference :var:)]
+ (in {analysis.#Extension extension (list indexA arrayA)}))))]))
(def: array::write
Handler
(custom
[($_ <>.and <code>.any <code>.any <code>.any)
(function (_ extension phase archive [indexC valueC arrayC])
- (do phase.monad
- [indexA (analysis/type.expecting Nat
- (phase archive indexC))
- [var_id varT] (analysis/type.check check.var)
- valueA (analysis/type.expecting varT
- (phase archive valueC))
- arrayA (analysis/type.expecting (type (Array varT))
- (phase archive arrayC))
- _ (analysis/type.inference (type (Array varT)))]
- (in {analysis.#Extension extension (list indexA valueA arrayA)})))]))
+ (<| analysis/type.with_var
+ (function (_ [@var :var:]))
+ (do phase.monad
+ [indexA (analysis/type.expecting Nat
+ (phase archive indexC))
+ valueA (analysis/type.expecting :var:
+ (phase archive valueC))
+ arrayA (analysis/type.expecting (type (Array :var:))
+ (phase archive arrayC))
+ _ (analysis/type.inference (type (Array :var:)))]
+ (in {analysis.#Extension extension (list indexA valueA arrayA)}))))]))
(def: array::delete
Handler
(custom
[($_ <>.and <code>.any <code>.any)
(function (_ extension phase archive [indexC arrayC])
- (do phase.monad
- [indexA (analysis/type.expecting Nat
- (phase archive indexC))
- [var_id varT] (analysis/type.check check.var)
- arrayA (analysis/type.expecting (type (Array varT))
- (phase archive arrayC))
- _ (analysis/type.inference (type (Array varT)))]
- (in {analysis.#Extension extension (list indexA arrayA)})))]))
+ (<| analysis/type.with_var
+ (function (_ [@var :var:]))
+ (do phase.monad
+ [indexA (analysis/type.expecting Nat
+ (phase archive indexC))
+ arrayA (analysis/type.expecting (type (Array :var:))
+ (phase archive arrayC))
+ _ (analysis/type.inference (type (Array :var:)))]
+ (in {analysis.#Extension extension (list indexA arrayA)}))))]))
(def: bundle::array
Bundle
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux
index 4f6a34452..eae384992 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux
@@ -31,68 +31,73 @@
(custom
[<c>.any
(function (_ extension phase archive lengthC)
- (do phase.monad
- [lengthA (<| (analysis/type.expecting Nat)
- (phase archive lengthC))
- [var_id varT] (analysis/type.check check.var)
- _ (analysis/type.inference (type (Array varT)))]
- (in {analysis.#Extension extension (list lengthA)})))]))
+ (<| analysis/type.with_var
+ (function (_ [@var :var:]))
+ (do phase.monad
+ [lengthA (<| (analysis/type.expecting Nat)
+ (phase archive lengthC))
+ _ (analysis/type.inference (type (Array :var:)))]
+ (in {analysis.#Extension extension (list lengthA)}))))]))
(def: array::length
Handler
(custom
[<c>.any
(function (_ extension phase archive arrayC)
- (do phase.monad
- [[var_id varT] (analysis/type.check check.var)
- arrayA (<| (analysis/type.expecting (type (Array varT)))
- (phase archive arrayC))
- _ (analysis/type.inference Nat)]
- (in {analysis.#Extension extension (list arrayA)})))]))
+ (<| analysis/type.with_var
+ (function (_ [@var :var:]))
+ (do phase.monad
+ [arrayA (<| (analysis/type.expecting (type (Array :var:)))
+ (phase archive arrayC))
+ _ (analysis/type.inference Nat)]
+ (in {analysis.#Extension extension (list arrayA)}))))]))
(def: array::read
Handler
(custom
[(<>.and <c>.any <c>.any)
(function (_ extension phase archive [indexC arrayC])
- (do phase.monad
- [indexA (<| (analysis/type.expecting Nat)
- (phase archive indexC))
- [var_id varT] (analysis/type.check check.var)
- arrayA (<| (analysis/type.expecting (type (Array varT)))
- (phase archive arrayC))
- _ (analysis/type.inference varT)]
- (in {analysis.#Extension extension (list indexA arrayA)})))]))
+ (<| analysis/type.with_var
+ (function (_ [@var :var:]))
+ (do phase.monad
+ [indexA (<| (analysis/type.expecting Nat)
+ (phase archive indexC))
+ arrayA (<| (analysis/type.expecting (type (Array :var:)))
+ (phase archive arrayC))
+ _ (analysis/type.inference :var:)]
+ (in {analysis.#Extension extension (list indexA arrayA)}))))]))
(def: array::write
Handler
(custom
[($_ <>.and <c>.any <c>.any <c>.any)
(function (_ extension phase archive [indexC valueC arrayC])
- (do phase.monad
- [indexA (<| (analysis/type.expecting Nat)
- (phase archive indexC))
- [var_id varT] (analysis/type.check check.var)
- valueA (<| (analysis/type.expecting varT)
- (phase archive valueC))
- arrayA (<| (analysis/type.expecting (type (Array varT)))
- (phase archive arrayC))
- _ (analysis/type.inference (type (Array varT)))]
- (in {analysis.#Extension extension (list indexA valueA arrayA)})))]))
+ (<| analysis/type.with_var
+ (function (_ [@var :var:]))
+ (do phase.monad
+ [indexA (<| (analysis/type.expecting Nat)
+ (phase archive indexC))
+ valueA (<| (analysis/type.expecting :var:)
+ (phase archive valueC))
+ arrayA (<| (analysis/type.expecting (type (Array :var:)))
+ (phase archive arrayC))
+ _ (analysis/type.inference (type (Array :var:)))]
+ (in {analysis.#Extension extension (list indexA valueA arrayA)}))))]))
(def: array::delete
Handler
(custom
[($_ <>.and <c>.any <c>.any)
(function (_ extension phase archive [indexC arrayC])
- (do phase.monad
- [indexA (<| (analysis/type.expecting Nat)
- (phase archive indexC))
- [var_id varT] (analysis/type.check check.var)
- arrayA (<| (analysis/type.expecting (type (Array varT)))
- (phase archive arrayC))
- _ (analysis/type.inference (type (Array varT)))]
- (in {analysis.#Extension extension (list indexA arrayA)})))]))
+ (<| analysis/type.with_var
+ (function (_ [@var :var:]))
+ (do phase.monad
+ [indexA (<| (analysis/type.expecting Nat)
+ (phase archive indexC))
+ arrayA (<| (analysis/type.expecting (type (Array :var:)))
+ (phase archive arrayC))
+ _ (analysis/type.inference (type (Array :var:)))]
+ (in {analysis.#Extension extension (list indexA arrayA)}))))]))
(def: bundle::array
Bundle
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux
index 944cac7a8..cbcfac6ec 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux
@@ -947,7 +947,7 @@
(^template [<tag>]
[(^ <tag>)
body])
- ([{//////synthesis.#Primitive _}]
+ ([{//////synthesis.#Simple _}]
[(//////synthesis.constant _)])
(^ (//////synthesis.variant [lefts right? sub]))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux
index e2ed832c1..ef4118721 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux
@@ -30,7 +30,8 @@
[archive
["[0]" unit]]
["[0]" cache "_"
- ["[1]" artifact]]]
+ [dependency
+ ["[1]" artifact]]]]
[reference
[variable {"+" Register Variable}]]]]]])
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux
index 59d88e612..9409ab00f 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux
@@ -28,7 +28,8 @@
[meta
[archive {"+" Archive}]
["[0]" cache "_"
- ["[1]" artifact]]]
+ [dependency
+ ["[1]" artifact]]]]
[reference
[variable {"+" Register}]]]]]])
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux
index 1e427dbfc..6d4193788 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux
@@ -29,7 +29,8 @@
[variable {"+" Register Variable}]]
[meta
["[0]" cache "_"
- ["[1]/[0]" artifact]]]]]]])
+ [dependency
+ ["[1]/[0]" artifact]]]]]]]])
(def: .public (apply expression archive [functionS argsS+])
(Generator (Reification Synthesis))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux
index 5249d2c55..f6a61ca8c 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux
@@ -28,7 +28,6 @@
["[0]" /// "_"
["[1][0]" reference]
["//[1]" /// "_"
- ["$" version]
["[1][0]" synthesis {"+" Synthesis}]
["[1][0]" generation]
["//[1]" ///
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux
index 428e3438c..d711e963a 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux
@@ -17,7 +17,8 @@
["/[1]" // "_"
["[1][0]" extension]
["/[1]" // "_"
- ["/" synthesis {"+" Synthesis Phase}]
+ ["/" synthesis {"+" Synthesis Phase}
+ ["[1][0]" simple]]
["[1][0]" analysis {"+" Analysis}
["[2][0]" simple]
["[2][0]" complex]]
@@ -26,32 +27,32 @@
[reference {"+"}
[variable {"+"}]]]]]])
-(def: (primitive analysis)
- (-> ///simple.Simple /.Primitive)
+(def: (simple analysis)
+ (-> ///simple.Simple /simple.Simple)
(case analysis
{///simple.#Unit}
- {/.#Text /.unit}
+ {/simple.#Text /.unit}
(^template [<analysis> <synthesis>]
[{<analysis> value}
{<synthesis> value}])
- ([///simple.#Bit /.#Bit]
- [///simple.#Frac /.#F64]
- [///simple.#Text /.#Text])
+ ([///simple.#Bit /simple.#Bit]
+ [///simple.#Frac /simple.#F64]
+ [///simple.#Text /simple.#Text])
(^template [<analysis> <synthesis>]
[{<analysis> value}
{<synthesis> (.i64 value)}])
- ([///simple.#Nat /.#I64]
- [///simple.#Int /.#I64]
- [///simple.#Rev /.#I64])))
+ ([///simple.#Nat /simple.#I64]
+ [///simple.#Int /simple.#I64]
+ [///simple.#Rev /simple.#I64])))
(def: (optimization archive)
Phase
(function (optimization' analysis)
(case analysis
{///analysis.#Simple analysis'}
- (phase#in {/.#Primitive (..primitive analysis')})
+ (phase#in {/.#Simple (..simple analysis')})
{///analysis.#Reference reference}
(phase#in {/.#Reference reference})
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux
index 4d6ec6354..8e37a6714 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux
@@ -248,7 +248,7 @@
(monad.each phase.monad (grow environment))
(phase#each (|>> {/.#Extension name})))
- {/.#Primitive _}
+ {/.#Simple _}
(phase#in expression)))
(def: .public (abstraction phase environment archive bodyA)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux
index 080bc436c..75ddb63b0 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux
@@ -1,24 +1,24 @@
(.using
- [library
- [lux "*"
- [abstract
- ["[0]" monad {"+" do}]]
- [control
- ["[0]" maybe ("[1]#[0]" monad)]]
- [data
- [collection
- ["[0]" list]]]
- [math
- [number
- ["n" nat]]]]]
- [////
- ["[0]" analysis {"+" Environment}
- ["[1]/[0]" complex]]
- ["/" synthesis {"+" Path Abstraction Synthesis}]
- [///
- [arity {"+" Arity}]
- ["[0]" reference
- ["[0]" variable {"+" Register Variable}]]]])
+ [library
+ [lux "*"
+ [abstract
+ ["[0]" monad {"+" do}]]
+ [control
+ ["[0]" maybe ("[1]#[0]" monad)]]
+ [data
+ [collection
+ ["[0]" list]]]
+ [math
+ [number
+ ["n" nat]]]]]
+ [////
+ ["[0]" analysis {"+" Environment}
+ ["[1]/[0]" complex]]
+ ["/" synthesis {"+" Path Abstraction Synthesis}]
+ [///
+ [arity {"+" Arity}]
+ ["[0]" reference
+ ["[0]" variable {"+" Register Variable}]]]])
(type: .public (Transform a)
(-> a (Maybe a)))
@@ -80,7 +80,7 @@
(loop [return? true
expr expr]
(case expr
- {/.#Primitive _}
+ {/.#Simple _}
{.#Some expr}
{/.#Structure structure}
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux
index 2d9e8ce5c..beccd504c 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux
@@ -1,31 +1,31 @@
(.using
- [library
- [lux "*"
- [abstract
- ["[0]" monad {"+" do}]]
- [control
- ["[0]" maybe ("[1]#[0]" functor)]
- ["[0]" try {"+" Try}]
- ["[0]" exception {"+" exception:}]]
- [data
- ["[0]" product]
- ["[0]" text
- ["%" format]]
- [collection
- ["[0]" dictionary {"+" Dictionary}]
- ["[0]" list ("[1]#[0]" functor mix)]
- ["[0]" set]]]
- [math
- [number
- ["n" nat]]]]]
- [////
- ["/" synthesis {"+" Path Synthesis}]
- ["[0]" analysis
- ["[1]/[0]" complex]]
- [///
- [arity {"+" Arity}]
- ["[0]" reference
- ["[0]" variable {"+" Register Variable}]]]])
+ [library
+ [lux "*"
+ [abstract
+ ["[0]" monad {"+" do}]]
+ [control
+ ["[0]" maybe ("[1]#[0]" functor)]
+ ["[0]" try {"+" Try}]
+ ["[0]" exception {"+" exception:}]]
+ [data
+ ["[0]" product]
+ ["[0]" text
+ ["%" format]]
+ [collection
+ ["[0]" dictionary {"+" Dictionary}]
+ ["[0]" list ("[1]#[0]" functor mix)]
+ ["[0]" set]]]
+ [math
+ [number
+ ["n" nat]]]]]
+ [////
+ ["/" synthesis {"+" Path Synthesis}]
+ ["[0]" analysis
+ ["[1]/[0]" complex]]
+ [///
+ [arity {"+" Arity}]
+ ["[0]" reference
+ ["[0]" variable {"+" Register Variable}]]]])
(def: (prune redundant register)
(-> Register Register Register)
@@ -108,7 +108,7 @@
(Remover Synthesis)
(function (again synthesis)
(case synthesis
- {/.#Primitive _}
+ {/.#Simple _}
synthesis
{/.#Structure structure}
@@ -331,7 +331,7 @@
(with_expansions [<no_op> (as_is {try.#Success [redundancy
synthesis]})]
(case synthesis
- {/.#Primitive _}
+ {/.#Simple _}
<no_op>
{/.#Structure structure}
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux
index 4f87318aa..99d99dbc6 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux
@@ -1,6 +1,6 @@
(.using
[library
- [lux {"-" Primitive Scope i64}
+ [lux {"-" Scope i64}
[abstract
[monad {"+" do}]
[equivalence {"+" Equivalence}]
@@ -24,16 +24,18 @@
["n" nat]
["i" int]
["f" frac]]]]]
- [//
- ["[0]" analysis {"+" Environment Analysis}
- ["[1]/[0]" complex {"+" Complex}]]
- [phase
- ["[0]" extension {"+" Extension}]]
- [///
- [arity {"+" Arity}]
- ["[0]" phase]
- ["[0]" reference {"+" Reference}
- ["[0]" variable {"+" Register Variable}]]]])
+ ["[0]" / "_"
+ ["[1][0]" simple {"+" Simple}]
+ [//
+ ["[0]" analysis {"+" Environment Analysis}
+ ["[1]/[0]" complex {"+" Complex}]]
+ [phase
+ ["[0]" extension {"+" Extension}]]
+ [///
+ [arity {"+" Arity}]
+ ["[0]" phase]
+ ["[0]" reference {"+" Reference}
+ ["[0]" variable {"+" Register Variable}]]]]])
(type: .public Resolver
(Dictionary Variable Variable))
@@ -53,13 +55,6 @@
[#locals 0
#currying? false])
-(type: .public Primitive
- (Variant
- {#Bit Bit}
- {#I64 (I64 Any)}
- {#F64 Frac}
- {#Text Text}))
-
(type: .public Side
(Either Nat Nat))
@@ -131,7 +126,7 @@
(type: .public Synthesis
(Rec Synthesis
(Variant
- {#Primitive Primitive}
+ {#Simple Simple}
{#Structure (Complex Synthesis)}
{#Reference Reference}
{#Control (Control Synthesis)}
@@ -225,12 +220,12 @@
(template [<name> <tag>]
[(template: .public (<name> content)
- [{..#Primitive {<tag> content}}])]
+ [{..#Simple {<tag> content}}])]
- [bit ..#Bit]
- [i64 ..#I64]
- [f64 ..#F64]
- [text ..#Text]
+ [bit /simple.#Bit]
+ [i64 /simple.#I64]
+ [f64 /simple.#F64]
+ [text /simple.#Text]
)
(template [<name> <tag>]
@@ -337,17 +332,8 @@
(def: .public (%synthesis value)
(Format Synthesis)
(case value
- {#Primitive primitive}
- (case primitive
- (^template [<pattern> <format>]
- [{<pattern> value}
- (<format> value)])
- ([#Bit %.bit]
- [#F64 %.frac]
- [#Text %.text])
-
- {#I64 value}
- (%.int (.int value)))
+ {#Simple it}
+ (/simple.format it)
{#Structure structure}
(case structure
@@ -435,38 +421,6 @@
(Format Path)
(%path' %synthesis))
-(implementation: .public primitive_equivalence
- (Equivalence Primitive)
-
- (def: (= reference sample)
- (case [reference sample]
- (^template [<tag> <eq> <format>]
- [[{<tag> reference'} {<tag> sample'}]
- (<eq> reference' sample')])
- ([#Bit bit#= %.bit]
- [#F64 f.= %.frac]
- [#Text text#= %.text])
-
- [{#I64 reference'} {#I64 sample'}]
- (i.= (.int reference') (.int sample'))
-
- _
- false)))
-
-(implementation: primitive_hash
- (Hash Primitive)
-
- (def: &equivalence ..primitive_equivalence)
-
- (def: hash
- (|>> (case> (^template [<tag> <hash>]
- [{<tag> value'}
- (# <hash> hash value')])
- ([#Bit bit.hash]
- [#F64 f.hash]
- [#Text text.hash]
- [#I64 i64.hash])))))
-
(def: side_equivalence
(Equivalence Side)
(sum.equivalence n.equivalence n.equivalence))
@@ -775,7 +729,7 @@
(^template [<tag> <equivalence>]
[[{<tag> reference'} {<tag> sample'}]
(# <equivalence> = reference' sample')])
- ([#Primitive ..primitive_equivalence]
+ ([#Simple /simple.equivalence]
[#Structure (analysis/complex.equivalence =)]
[#Reference reference.equivalence]
[#Control (control_equivalence =)]
@@ -799,7 +753,7 @@
(^template [<tag> <hash>]
[{<tag> value}
(# <hash> hash value)])
- ([#Primitive ..primitive_hash]
+ ([#Simple /simple.hash]
[#Structure (analysis/complex.hash again_hash)]
[#Reference reference.hash]
[#Control (..control_hash again_hash)]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/simple.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/simple.lux
new file mode 100644
index 000000000..0b1825953
--- /dev/null
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/simple.lux
@@ -0,0 +1,70 @@
+(.using
+ [library
+ [lux "*"
+ [abstract
+ [equivalence {"+" Equivalence}]
+ [hash {"+" Hash}]]
+ [control
+ [pipe {"+" case>}]]
+ [data
+ ["[0]" bit ("[1]#[0]" equivalence)]
+ ["[0]" text ("[1]#[0]" equivalence)
+ ["%" format]]]
+ [math
+ [number
+ ["[0]" i64]
+ ["n" nat]
+ ["i" int]
+ ["f" frac]]]]])
+
+(type: .public Simple
+ (Variant
+ {#Bit Bit}
+ {#I64 (I64 Any)}
+ {#F64 Frac}
+ {#Text Text}))
+
+(def: .public (format it)
+ (%.Format Simple)
+ (case it
+ (^template [<pattern> <format>]
+ [{<pattern> value}
+ (<format> value)])
+ ([#Bit %.bit]
+ [#F64 %.frac]
+ [#Text %.text])
+
+ {#I64 value}
+ (%.int (.int value))))
+
+(implementation: .public equivalence
+ (Equivalence Simple)
+
+ (def: (= reference sample)
+ (case [reference sample]
+ (^template [<tag> <eq> <format>]
+ [[{<tag> reference'} {<tag> sample'}]
+ (<eq> reference' sample')])
+ ([#Bit bit#= %.bit]
+ [#F64 f.= %.frac]
+ [#Text text#= %.text])
+
+ [{#I64 reference'} {#I64 sample'}]
+ (i.= (.int reference') (.int sample'))
+
+ _
+ false)))
+
+(implementation: .public hash
+ (Hash Simple)
+
+ (def: &equivalence ..equivalence)
+
+ (def: hash
+ (|>> (case> (^template [<factor> <tag> <hash>]
+ [{<tag> value'}
+ (n.* <factor> (# <hash> hash value'))])
+ ([1 #Bit bit.hash]
+ [2 #F64 f.hash]
+ [3 #Text text.hash]
+ [5 #I64 i64.hash])))))
diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/unit.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/unit.lux
index fb7cc745b..ed2e00876 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/archive/unit.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/archive/unit.lux
@@ -6,6 +6,8 @@
[hash {"+" Hash}]]
[data
["[0]" product]
+ [text
+ ["%" format]]
[collection
["[0]" set {"+" Set}]]]
[math
@@ -33,3 +35,9 @@
(def: .public none
(Set ID)
(set.empty ..hash))
+
+(def: .public (format it)
+ (%.Format ID)
+ (%.format (%.nat (value@ #module it))
+ "."
+ (%.nat (value@ #artifact it))))
diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/artifact.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/artifact.lux
index 327cae965..9bce830d6 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/artifact.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/artifact.lux
@@ -76,7 +76,7 @@
(def: (references value)
(-> Synthesis (List Constant))
(case value
- {synthesis.#Primitive value}
+ {synthesis.#Simple value}
(list)
{synthesis.#Structure value}
diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux
index ae6b02e1e..faa8e0f86 100644
--- a/stdlib/source/test/lux/data/text.lux
+++ b/stdlib/source/test/lux/data/text.lux
@@ -266,8 +266,7 @@
(_.for [/.equivalence]
($equivalence.spec /.equivalence (random.ascii 2)))
(_.for [/.hash]
- (|> (random.ascii 1)
- ($hash.spec /.hash)))
+ ($hash.spec /.hash (random.ascii 1)))
(_.for [/.order]
($order.spec /.order (random.ascii 2)))
(_.for [/.monoid]
diff --git a/stdlib/source/test/lux/extension.lux b/stdlib/source/test/lux/extension.lux
index 85b98df02..b2dde4019 100644
--- a/stdlib/source/test/lux/extension.lux
+++ b/stdlib/source/test/lux/extension.lux
@@ -178,15 +178,13 @@
@.python (python.comment commentary
(python.statement (python.string commentary)))
@.lua (lua.comment commentary
- (lua.statement (lua.string commentary)))
+ (lua.statement expressionG))
@.ruby (ruby.comment commentary
(ruby.statement (ruby.string commentary)))]))]
(generation.log! commentary))))]
(in directive.no_requirements)))
- (for [... TODO: No longer skip testing Lua after Rembulan isn't being used anymore.
- @.lua (as_is)]
- (`` ((~~ (static ..directive)) (n.* 2 3))))
+ (`` ((~~ (static ..directive)) (n.* 2 3)))
))
(def: .public test
diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux
index 765ea00e3..14f3d201a 100644
--- a/stdlib/source/test/lux/ffi.jvm.lux
+++ b/stdlib/source/test/lux/ffi.jvm.lux
@@ -151,7 +151,9 @@
(# ! each (|>> /.as_double)))
character (# ! each (|>> /.as_int /.int_to_char) random.int)
string (# ! each (|>> /.as_string)
- (random.ascii 1))]
+ (random.ascii 1))
+
+ bit/0 random.bit]
($_ _.and
(_.cover [/.check]
(and (case (/.check java/lang/String sample) {.#Some _} true {.#None} false)
@@ -182,25 +184,45 @@
/.!!!
/.null?
not)))
- (~~ (template [<object> <primitive> <value> <=>]
- [(|> <value>
- (: <object>)
- "jvm object cast"
- (: <primitive>)
- "jvm object cast"
- (: <object>)
- (<=> <value>)
- (_.cover [<object> <primitive>]))]
-
- [/.Boolean /.boolean boolean boolean#=]
- [/.Byte /.byte byte byte#=]
- [/.Short /.short short short#=]
- [/.Integer /.int integer integer#=]
- [/.Long /.long long long#=]
- [/.Float /.float float float#=]
- [/.Double /.double double double#=]
- [/.Character /.char character character#=]
+ (~~ (template [<object> <primitive> <jvm#value> <jvm#=>
+ <lux#value> <as> <of> <lux#=>]
+ [(_.cover [<object> <primitive>]
+ (|> <jvm#value>
+ (: <object>)
+ "jvm object cast"
+ (: <primitive>)
+ "jvm object cast"
+ (: <object>)
+ (<jvm#=> <jvm#value>)))
+ (_.cover [<as> <of>]
+ (|> <lux#value>
+ <as>
+ <of>
+ (<lux#=> <lux#value>)))]
+
+ [/.Boolean /.boolean boolean boolean#=
+ bit/0 /.as_boolean /.of_boolean bit#=]
+ [/.Byte /.byte byte byte#=
+ (/.of_byte byte) /.as_byte /.of_byte i#=]
+ [/.Short /.short short short#=
+ (/.of_short short) /.as_short /.of_short i#=]
+ [/.Integer /.int integer integer#=
+ (/.of_int integer) /.as_int /.of_int i#=]
+ [/.Long /.long long long#=
+ (/.of_long long) /.as_long /.of_long i#=]
+ [/.Float /.float float float#=
+ (/.of_float float) /.as_float /.of_float f#=]
+ [/.Double /.double double double#=
+ (/.of_double double) /.as_double /.of_double f#=]
+ [/.Character /.char character character#=
+ (/.of_char character) /.as_char /.of_char i#=]
))
+ (_.cover [/.as_string /.of_string]
+ (let [it (/.of_string string)]
+ (|> it
+ /.as_string
+ /.of_string
+ (text#= it))))
(_.cover [/.cannot_cast_to_non_object]
(text.contains? (value@ exception.#label /.cannot_cast_to_non_object)
(macro_error (/.:as boolean (: /.Boolean boolean)))))
diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux
index 265f0a0c6..c1b0a83bd 100644
--- a/stdlib/source/test/lux/tool.lux
+++ b/stdlib/source/test/lux/tool.lux
@@ -12,6 +12,8 @@
[lux
... ["[1][0]" syntax]
["[1][0]" analysis]
+ ["[1][0]" synthesis "_"
+ ["[1]/[0]" simple]]
["[1][0]" phase "_"
["[1]/[0]" extension]
["[1]/[0]" analysis]
@@ -34,6 +36,7 @@
/reference.test
/phase.test
/analysis.test
+ /synthesis/simple.test
/meta/archive.test
/meta/cli.test
/meta/export.test
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/simple.lux b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/simple.lux
new file mode 100644
index 000000000..568788a0e
--- /dev/null
+++ b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/simple.lux
@@ -0,0 +1,45 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ [abstract
+ [monad {"+" do}]
+ [\\specification
+ ["$[0]" equivalence]
+ ["$[0]" hash]]]
+ [data
+ ["[0]" bit ("[1]#[0]" equivalence)]
+ ["[0]" text ("[1]#[0]" equivalence)]]
+ [math
+ ["[0]" random {"+" Random}]
+ [number
+ ["n" nat]]]]]
+ [\\library
+ ["[0]" /]])
+
+(def: .public random
+ (Random /.Simple)
+ ($_ random.or
+ random.bit
+ random.i64
+ random.frac
+ (random.ascii/lower 1)
+ ))
+
+(def: .public test
+ Test
+ (<| (_.covering /._)
+ (_.for [/.Simple])
+ (do [! random.monad]
+ [left ..random
+ right ..random]
+ ($_ _.and
+ (_.for [/.equivalence]
+ ($equivalence.spec /.equivalence ..random))
+ (_.for [/.hash]
+ ($hash.spec /.hash ..random))
+
+ (_.cover [/.format]
+ (bit#= (text#= (/.format left) (/.format right))
+ (# /.equivalence = left right)))
+ ))))