Skip to content

Commit

Permalink
Improvements to function application.
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoejp committed Aug 30, 2023
1 parent b7fb27e commit c7daf84
Show file tree
Hide file tree
Showing 23 changed files with 287 additions and 265 deletions.
4 changes: 4 additions & 0 deletions documentation/bookmark/compilation/target/objective_c.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Reference

0. [Objective-C Internals](https://alwaysprocessing.blog/series/objc-internals)

4 changes: 4 additions & 0 deletions documentation/bookmark/linguistics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Reference

0. [Garden-path sentence](https://en.wikipedia.org/wiki/Garden-path_sentence)

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Reference

0. [CausalPy - causal inference for quasi-experiments](https://causalpy.readthedocs.io/en/latest/)
0. [A First Course in Causal Inference](https://arxiv.org/abs/2305.18793)

2 changes: 1 addition & 1 deletion documentation/bookmark/paradigm/logic_programming.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

# Unification

0. []()
0. [Functors of the World, Unite!](https://www.youtube.com/watch?v=8k7YH9st_8U)

# Inspiration
Expand All @@ -15,6 +14,7 @@

# Reference

0. [Dis-unification](https://en.wikipedia.org/wiki/Dis-unification_(computer_science))
0. [Rethinking Prolog](https://okmij.org/ftp/kakuritu/rethinking.pdf)
0. [Symbolic artificial intelligence at Pipedrive](https://medium.com/pipedrive-engineering/symbolic-artificial-intelligence-at-pipedrive-a9bd36d06b9e)
0. [PrologHub](https://prologhub.com/)
Expand Down
1 change: 1 addition & 0 deletions documentation/bookmark/software/architecture.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Reference

0. [How Agility Enhances Software Architecture](https://www.agile-meets-architecture.com/essays/how-agility-enhances-software-architecture)
0. [Feature-Sliced Design: Architectural methodology for frontend projects](https://feature-sliced.design/)
0. [Why Do We Create System Architecture Diagrams Anyway?](https://www.ilograph.com/blog/posts/why-create-system-architecture-diagrams/)
0. [A Syntactic Theory of Software Architecture](https://www.panda.sys.t.u-tokyo.ac.jp/kushiro/ReferencePaper/Pattern&Framework/00385969.pdf)
Expand Down
4 changes: 4 additions & 0 deletions documentation/bookmark/ui__user_interface/server_driven.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Reference

0. [Sending UI over APIs](https://www.builder.io/blog/ui-over-apis)

30 changes: 15 additions & 15 deletions lux-python/source/program.lux
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,14 @@
{try.#Success ((as Macro' macro) inputs lux)})))

(with_expansions [<jvm> (the host
(IO (Host (_.Expression Any) (_.Statement Any)))
(IO (Host _.Expression _.Statement))
(io (let [interpreter (org/python/util/PythonInterpreter::new [])
evaluate! (is (-> [(Maybe unit.ID) (_.Expression Any)] (Try Any))
evaluate! (is (-> [(Maybe unit.ID) _.Expression] (Try Any))
(function (evaluate! [_ input])
(do try.monad
[output (org/python/util/PythonInterpreter::eval [(ffi.as_string (_.code input))] interpreter)]
(..read output))))
execute! (is (-> (_.Statement Any) (Try Any))
execute! (is (-> _.Statement (Try Any))
(function (execute! input)
(when (org/python/util/PythonInterpreter::exec [(ffi.as_string (_.code input))] interpreter)
{try.#Failure error}
Expand All @@ -427,7 +427,7 @@

output
output)))]
(is (Host (_.Expression Any) (_.Statement Any))
(is (Host _.Expression _.Statement)
(implementation
(the evaluate evaluate!)
(the execute execute!)
Expand All @@ -445,7 +445,7 @@
(|> content
(of utf8.format projection)
try.trusted
(as (_.Statement Any))))
(as _.Statement)))

(the (re_learn context custom content)
(execute! content))
Expand All @@ -462,16 +462,16 @@
(import (eval [ffi.String ffi.Dict] "try" Any))

(the host
(IO (Host (_.Expression Any) (_.Statement Any)))
(io (is (Host (_.Expression Any) (_.Statement Any))
(IO (Host _.Expression _.Statement))
(io (is (Host _.Expression _.Statement)
(let [globals (..dict [])
evaluate! (is (-> (_.Expression Any) (Try Any))
evaluate! (is (-> _.Expression (Try Any))
(function (evaluate! input)
(..eval [(_.code input) globals])))
execute! (is (-> (_.Statement Any) (Try Any))
execute! (is (-> _.Statement (Try Any))
(function (execute! input)
(ffi.try (.python_exec# (_.code input) globals))))
define! (is (-> unit.ID (_.Expression Any) (Try [Text Any (_.Statement Any)]))
define! (is (-> unit.ID _.Expression (Try [Text Any _.Statement]))
(function (define! context input)
(let [global (reference.artifact context)
@global (_.var global)]
Expand All @@ -489,7 +489,7 @@
(|> content
(of utf8.format projection)
try.trusted
(as (_.Statement Any))))
(as _.Statement)))

(the (re_learn context content)
(execute! content))
Expand Down Expand Up @@ -536,7 +536,7 @@
(|>> as_expected))))

(the platform
(IO (Platform Register (_.Expression Any) (_.Statement Any)))
(IO (Platform Register _.Expression _.Statement))
(do io.monad
[host ..host]
(in [platform.#file_system (file.async file.default)
Expand All @@ -547,7 +547,7 @@
platform.#write (|>> _.code (of utf8.format injection))])))

(the (lux_program context program)
(Program (_.Expression Any) (_.Statement Any))
(Program _.Expression _.Statement)
(all _.then
(_.import "sys")
(_.when (_.= (_.string "__main__") (_.var "__name__"))
Expand All @@ -564,7 +564,7 @@
(async.future (of world/environment.default exit +0)))

(the (scope body)
(-> (_.Statement Any) (_.Statement Any))
(-> _.Statement _.Statement)
(let [@program (_.var "lux_program")
; _.statement
$sys (_.__import__/1 (_.unicode "sys"))
Expand Down Expand Up @@ -600,7 +600,7 @@
(reference.constant python/reference.system)
..extender
service
[(packager.package (is (_.Statement Any) (_.manual ""))
[(packager.package (is _.Statement (_.manual ""))
_.code
_.then
..scope)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
(the .public (custom [projection handler])
(for_any (_ s)
(-> [(Projection s)
(-> Phase Archive s (Operation (Expression Any)))]
(-> Phase Archive s (Operation Expression))]
Handler))
(function (_ phase archive input)
(when (<synthesis>.value projection input)
Expand All @@ -65,7 +65,7 @@
[@ {synthesis.#Extension [.prelude "when_char#|translation"] parameters}]
(do phase.monad
[body (expression archive synthesis)]
(in (as (Statement Any) body)))
(in (as Statement body)))

(^.with_template [<tag>]
[(<tag> @ value)
Expand Down Expand Up @@ -114,8 +114,8 @@
[inputG (phase archive input)
else! (..statement phase archive else)
@input (of ! each _.var (translation.symbol "input"))
conditionals! (is (Operation (List [(Expression Any)
(Statement Any)]))
conditionals! (is (Operation (List [Expression
Statement]))
(monad.each ! (function (_ [chars branch])
(do !
[branch! (..statement phase archive branch)]
Expand Down Expand Up @@ -147,8 +147,8 @@
... _ (translation.save! (product.right artifact_id) {.#None} closure)
]
... (in (_.apply @closure dependencies))
(in (<| (as (Expression Any))
(is (Statement Any))
(in (<| (as Expression)
(is Statement)
(all _.then
(_.set (list @input) inputG)
(list#mix (function (_ [test then!] else!)
Expand All @@ -163,8 +163,8 @@
(dictionary.has "try#|translation" (unary //runtime.lux::try))))

(the (capped operation parameter subject)
(-> (-> (Expression Any) (Expression Any) (Expression Any))
(-> (Expression Any) (Expression Any) (Expression Any)))
(-> (-> Expression Expression Expression)
(-> Expression Expression Expression))
(//runtime.i64::64 (operation parameter subject)))

(the with_i64_extensions
Expand Down Expand Up @@ -205,15 +205,15 @@
(dictionary.has "f64_int#|translation" (unary _.int/1))))

(the (text::clip [paramO extraO subjectO])
(Trinary (Expression Any))
(Trinary Expression)
(//runtime.text::clip paramO extraO subjectO))

(the (text::index [startO partO textO])
(Trinary (Expression Any))
(Trinary Expression)
(//runtime.text::index startO partO textO))

(the text::composite
(Variadic (Expression Any))
(Variadic Expression)
(|>> (|.when (list)
(_.string "")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@
["<s>" \\projection]]]]])

(the (array::new size)
(Unary (Expression Any))
(Unary Expression)
(|> (list _.none)
_.list
(_.* size)))

(the array::length
(Unary (Expression Any))
(Unary Expression)
(|>> _.len/1 //runtime.i64::64))

(the (array::read [indexG arrayG])
(Binary (Expression Any))
(Binary Expression)
(_.item indexG arrayG))

(the (array::write [indexG valueG arrayG])
(Trinary (Expression Any))
(Trinary Expression)
(//runtime.array::write indexG valueG arrayG))

(the (array::delete [indexG arrayG])
(Binary (Expression Any))
(Binary Expression)
(//runtime.array::write indexG _.none arrayG))

(the with_array_extensions
Expand Down Expand Up @@ -84,8 +84,8 @@
(in (_.do methodS inputsG objectG))))]))

(with_template [<!> <?> <unit>]
[(the <!> (Nullary (Expression Any)) (function.constant <unit>))
(the <?> (Unary (Expression Any)) (_.= <unit>))]
[(the <!> (Nullary Expression) (function.constant <unit>))
(the <?> (Unary Expression) (_.= <unit>))]

[object::none object::none? _.none]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,15 @@
initialize_self!
(list.indices arity))]
environment (monad.each ! (expression archive) environment)
_ (do !
[.let [procedure_definition (..procedure environment procedure_id arity body!)]
_ (translation.execute! procedure_definition)]
(translation.save! (unit.artifact procedure_id) {.#None} procedure_definition))
_ (when environment
(list)
(do !
[.let [procedure_definition (..procedure environment procedure_id arity body!)]
_ (translation.execute! procedure_definition)]
(translation.save! (unit.artifact procedure_id) {.#None} procedure_definition))

else
(in []))
.let [[definition instantiation] (with_closure @self environment
(all _.then
(_.define @num_args (_.its "length" @@arguments))
Expand All @@ -183,26 +188,26 @@
(<| (_.with_label (_.label @scope))
(_.do_while (_.boolean true))
body!)))
(_.if (|> @num_args (_.> arityO))
(let [arity_inputs (|> (_.array (list))
(_.its "slice")
(_.do "call" (list @@arguments (_.i32 +0) arityO)))
extra_inputs (|> (_.array (list))
(_.its "slice")
(_.do "call" (list @@arguments arityO)))]
(_.return (|> @self
(apply_poly arity_inputs)
(apply_poly extra_inputs)))))
... (|> @num_args (_.< arityO))
(let [all_inputs (|> (_.array (list))
(_.its "slice")
(_.do "call" (list @@arguments)))]
(all _.then
(_.define @curried all_inputs)
(_.return (_.closure (list)
(let [@missing all_inputs]
(_.return (apply_poly (_.do "concat" (list @missing) @curried)
@self))))))))
(_.if (|> @num_args (_.< arityO))
(let [all_inputs (|> (_.array (list))
(_.its "slice")
(_.do "call" (list @@arguments)))]
(all _.then
(_.define @curried all_inputs)
(_.return (_.closure (list)
(let [@missing all_inputs]
(_.return (apply_poly (_.do "concat" (list @missing) @curried)
@self))))))))
... (|> @num_args (_.> arityO))
(let [arity_inputs (|> (_.array (list))
(_.its "slice")
(_.do "call" (list @@arguments (_.i32 +0) arityO)))
extra_inputs (|> (_.array (list))
(_.its "slice")
(_.do "call" (list @@arguments arityO)))]
(_.return (|> @self
(apply_poly arity_inputs)
(apply_poly extra_inputs)))))
))]
_ (translation.execute! definition)
_ (translation.save! (product.right abstraction_id) {.#None} definition)]
Expand Down
Loading

0 comments on commit c7daf84

Please sign in to comment.