aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library')
-rw-r--r--stdlib/source/library/lux.lux48
-rw-r--r--stdlib/source/library/lux/ffi.js.lux51
-rw-r--r--stdlib/source/library/lux/ffi.jvm.lux2
-rw-r--r--stdlib/source/library/lux/meta/annotation.lux16
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux79
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux47
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux2
8 files changed, 99 insertions, 148 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux
index 804c27ee5..d717434be 100644
--- a/stdlib/source/library/lux.lux
+++ b/stdlib/source/library/lux.lux
@@ -50,9 +50,7 @@
(2 #0 (4 #0 1)
(9 #0 (4 #0 1) (4 #0 0))))))
[dummy_location
- (9 #1 (0 #1 [[dummy_location (7 #0 ["library/lux" "type_args"])]
- [dummy_location (9 #0 (0 #1 [dummy_location (5 #0 "a")] (0 #0)))]]
- (0 #0)))]
+ (9 #1 (0 #0))]
("End" "Item")
#1)
@@ -132,9 +130,7 @@
... "lux.Some"
(4 #0 1))))
[dummy_location
- (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "type_args"])]
- [dummy_location (9 #0 (#Item [dummy_location (5 #0 "a")] #End))]]
- #End))]
+ (9 #1 #End)]
("None" "Some")
#1)
@@ -221,9 +217,7 @@
(#Product (#Parameter 3)
(#Parameter 1)))))
[dummy_location
- (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "type_args"])]
- [dummy_location (9 #0 (#Item [dummy_location (5 #0 "m")] (#Item [dummy_location (5 #0 "v")] #End)))]]
- #End))]
+ (9 #1 #End)]
["meta" "datum"]
#1)
@@ -273,9 +267,7 @@
(#Parameter 0))
(#Parameter 1)))))
[dummy_location
- (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "type_args"])]
- [dummy_location (9 #0 (#Item [dummy_location (5 #0 "w")] #End))]]
- #End))]
+ (9 #1 #End)]
("Bit" "Nat" "Int" "Rev" "Frac" "Text" "Identifier" "Tag" "Form" "Tuple" "Record")
#1)
@@ -462,9 +454,7 @@
(#Apply (#Product (#Parameter 3)
(#Parameter 1))
List)))))
- (record$ (#Item [(tag$ ["library/lux" "type_args"])
- (tuple$ (#Item (text$ "k") (#Item (text$ "v") #End)))]
- #End))
+ (record$ #End)
["counter" "mappings"]
.public)
@@ -517,9 +507,7 @@
(#Parameter 3)
... "lux.Right"
(#Parameter 1)))))
- (record$ (#Item [(tag$ ["library/lux" "type_args"])
- (tuple$ (#Item (text$ "l") (#Item (text$ "r") #End)))]
- #End))
+ (record$ #End)
("Left" "Right")
.public)
@@ -707,9 +695,7 @@
(#Function Lux
(#Apply (#Product Lux (#Parameter 1))
(#Apply Text Either))))))
- (record$ (#Item [(tag$ ["library/lux" "type_args"])
- (tuple$ (#Item (text$ "a") #End))]
- #End))
+ (record$ #End)
.public)
... (type: .public Macro'
@@ -2794,24 +2780,6 @@
(~ (definition_annotation_value v))])))
kvs)))
-(def:' .private (with_function_parameters parameters meta)
- (-> (List Code) Code Code)
- (case parameters
- #End
- meta
-
- _
- (` (#.Item [[(~ location_code) (#.Tag ["library/lux" "func_args"])]
- [(~ location_code) (#.Tuple (.list (~+ (list\each (function (_ parameter)
- (` [(~ location_code) (#.Text (~ (text$ (code\encoded parameter))))]))
- parameters))))]]
- (~ meta)))))
-
-(def:' .private (with_type_args args)
- (-> (List Code) Code)
- (` {#.type_args [(~+ (list\each (function (_ arg) (text$ (code\encoded arg)))
- args))]}))
-
(def:' .private (endP tokens)
(-> (List Code) (Maybe Any))
(case tokens
@@ -2998,7 +2966,7 @@
(in_meta (list (` ("lux def" (~ (..local_identifier$ name))
(~ body)
[(~ location_code)
- (#.Record (~ (with_function_parameters parameters =annotations)))]
+ (#.Record (~ =annotations))]
(~ export_policy))))))
#None
diff --git a/stdlib/source/library/lux/ffi.js.lux b/stdlib/source/library/lux/ffi.js.lux
index 247894177..6a130d4a1 100644
--- a/stdlib/source/library/lux/ffi.js.lux
+++ b/stdlib/source/library/lux/ffi.js.lux
@@ -23,11 +23,15 @@
["." template]]]])
(abstract: .public (Object brand)
+ {}
+
Any)
(template [<name>]
[(with_expansions [<brand> (template.identifier [<name> "'"])]
(abstract: <brand>
+ {}
+
Any
(type: .public <name>
@@ -153,7 +157,6 @@
input))
(def: .public (null _)
- {#.doc (example "The null pointer.")}
(-> Any Nothing)
(:expected ("js object null")))
@@ -238,18 +241,6 @@
(~+ (list\each (with_null g!temp) g!inputs)))))))))))
(syntax: .public (import: [import ..import])
- {#.doc (example "Easily import types, methods, functions and constants."
- (import: Uint8Array)
-
- (import: TextEncoder
- ["#::."
- (new [..String])
- (encode [..String] Uint8Array)])
-
- (import: TextDecoder
- ["#::."
- (new [..String])
- (decode [..String] String)]))}
(with_identifiers [g!temp g!_]
(case import
(#Class [[class_name class_parameters] format members])
@@ -337,17 +328,10 @@
)))
(template: .public (type_of object)
- {#.doc (example "The type of an object, as text."
- (and (= "boolean" (type_of #1))
- (= "number" (type_of +123.456))
- (= "string" (type_of "789"))
- (= "function" (type_of (function (_ value) value)))))}
- ("js type-of" object))
+ [("js type-of" object)])
(syntax: .public (constant [type <code>.any
[head tail] (<code>.tuple (<>.and <code>.local_identifier (<>.some <code>.local_identifier)))])
- {#.doc (example "Allows using definitions from the JavaScript host platform."
- (constant .Frac [Math PI]))}
(with_identifiers [g!_]
(let [constant (` ("js constant" (~ (code.text head))))]
(case tail
@@ -372,12 +356,12 @@
(~+ (list\each code.local_identifier tail))])))))))))))
(template: (!defined? <constant>)
- (.case (..constant Any <constant>)
- #.None
- .false
+ [(.case (..constant Any <constant>)
+ #.None
+ .false
- (#.Some _)
- .true))
+ (#.Some _)
+ .true)])
(template [<name> <constant>]
[(def: .public <name>
@@ -404,13 +388,8 @@
false))
(template: .public (closure <inputs> <output>)
- {#.doc (example "Allows defining closures/anonymous-functions in the form that JavaScript expects."
- "This is useful for adapting Lux functions for usage by JavaScript code."
- (: ..Function
- (closure [left right]
- (do_something (:as Foo left) (:as Bar right)))))}
- (.:as ..Function
- (`` ("js function"
- (~~ (template.amount <inputs>))
- (.function (_ [<inputs>])
- <output>)))))
+ [(.:as ..Function
+ (`` ("js function"
+ (~~ (template.amount <inputs>))
+ (.function (_ [<inputs>])
+ <output>))))])
diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux
index e50f12602..412f5c0d6 100644
--- a/stdlib/source/library/lux/ffi.jvm.lux
+++ b/stdlib/source/library/lux/ffi.jvm.lux
@@ -932,7 +932,7 @@
(def: (import_member_args^ type_vars)
(-> (List (Type Var)) (Parser (List [Bit (Type Value)])))
- (<code>.tuple (<>.some (<>.and (<>.parses? (<code>.tag! ["" "?"]))
+ (<code>.tuple (<>.some (<>.and (<>.parses? (<code>.this! (' "?")))
(..type^ type_vars)))))
(def: import_member_return_flags^
diff --git a/stdlib/source/library/lux/meta/annotation.lux b/stdlib/source/library/lux/meta/annotation.lux
index d2cc9a45a..5617cd88c 100644
--- a/stdlib/source/library/lux/meta/annotation.lux
+++ b/stdlib/source/library/lux/meta/annotation.lux
@@ -56,10 +56,6 @@
[record #.Record (List [Code Code])]
)
-(def: .public documentation
- (-> Annotation (Maybe Text))
- (..text (name_of #.doc)))
-
(def: .public (flagged? flag)
(-> Name Annotation Bit)
(|>> (..bit flag) (maybe.else false)))
@@ -76,15 +72,3 @@
_
#.None))
-
-(template [<name> <tag>]
- [(def: .public (<name> ann)
- (-> Annotation (List Text))
- (<| (maybe.else (list))
- (do {! maybe.monad}
- [args (..tuple (name_of <tag>) ann)]
- (monad.each ! ..text_parser args))))]
-
- [function_arguments #.func_args]
- [type_arguments #.type_args]
- )
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux
index 3aad68a7f..be57d4c55 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux
@@ -25,12 +25,18 @@
[extension (#+ Nullary Unary Binary Trinary
nullary unary binary trinary)]
["//" js #_
- ["#." runtime (#+ Operation Phase Handler Bundle Generator)]
- ["#." primitive]]]
+ ["#." runtime (#+ Operation Phase Phase! Handler Bundle Generator)]
+ ["#." primitive]
+ ["#." structure]
+ ["#." reference]
+ ["#." case]
+ ["#." loop]
+ ["#." function]]]
[//
- [synthesis (#+ %synthesis)]
+ [analysis (#+)]
+ ["." synthesis (#+ %synthesis)]
[///
- ["#" phase]]]]])
+ ["#" phase ("#\." monad)]]]]])
(def: .public (custom [parser handler])
(All (_ s)
@@ -91,6 +97,48 @@
(//runtime.io//log messageG)
//runtime.unit))
+(def: .public (statement expression archive synthesis)
+ Phase!
+ (case synthesis
+ ... TODO: Get rid of this ASAP
+ (#synthesis.Extension "lux syntax char case!" parameters)
+ (do /////.monad
+ [body (expression archive synthesis)]
+ (in (:as Statement body)))
+
+ (^template [<tag>]
+ [(^ (<tag> value))
+ (/////\each _.return (expression archive synthesis))])
+ ([synthesis.bit]
+ [synthesis.i64]
+ [synthesis.f64]
+ [synthesis.text]
+ [synthesis.variant]
+ [synthesis.tuple]
+ [#synthesis.Reference]
+ [synthesis.branch/get]
+ [synthesis.function/apply]
+ [#synthesis.Extension])
+
+ (^ (synthesis.branch/case case))
+ (//case.case! statement expression archive case)
+
+ (^ (synthesis.branch/let let))
+ (//case.let! statement expression archive let)
+
+ (^ (synthesis.branch/if if))
+ (//case.if! statement expression archive if)
+
+ (^ (synthesis.loop/scope scope))
+ (//loop.scope! statement expression archive scope)
+
+ (^ (synthesis.loop/recur updates))
+ (//loop.recur! statement expression archive updates)
+
+ (^ (synthesis.function/abstraction abstraction))
+ (/////\each _.return (//function.function statement expression archive abstraction))
+ ))
+
... TODO: Get rid of this ASAP
(def: lux::syntax_char_case!
(..custom [($_ <>.and
@@ -102,20 +150,25 @@
(function (_ extension_name phase archive [input else conditionals])
(do {! /////.monad}
[inputG (phase archive input)
- elseG (phase archive else)
- conditionalsG (: (Operation (List [(List Literal)
+ else! (..statement phase archive else)
+ conditionals! (: (Operation (List [(List Literal)
Statement]))
(monad.each ! (function (_ [chars branch])
(do !
- [branchG (phase archive branch)]
+ [branch! (..statement phase archive branch)]
(in [(list\each (|>> .int _.int) chars)
- (_.return branchG)])))
+ branch!])))
conditionals))]
- (in (_.apply/* (_.closure (list)
- (_.switch (_.the //runtime.i64_low_field inputG)
- conditionalsG
- (#.Some (_.return elseG))))
- (list)))))]))
+ ... (in (_.apply/* (_.closure (list)
+ ... (_.switch (_.the //runtime.i64_low_field inputG)
+ ... conditionals!
+ ... (#.Some (_.return else!))))
+ ... (list)))
+ (in (<| (:as Expression)
+ (: Statement)
+ (_.switch (_.the //runtime.i64_low_field inputG)
+ conditionals!
+ (#.Some else!))))))]))
... [Bundles]
(def: lux_procs
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux
index 61119e473..c240161ee 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux
@@ -18,7 +18,10 @@
["/#" // #_
["#." reference]
["/#" // #_
- ["#." extension]
+ ["#." extension
+ [generation
+ [js
+ ["#/." common]]]]
["/#" // #_
[analysis (#+)]
["." synthesis]
@@ -27,42 +30,6 @@
[reference (#+)
[variable (#+)]]]]]]])
-(def: (statement expression archive synthesis)
- Phase!
- (case synthesis
- (^template [<tag>]
- [(^ (<tag> value))
- (//////phase\each _.return (expression archive synthesis))])
- ([synthesis.bit]
- [synthesis.i64]
- [synthesis.f64]
- [synthesis.text]
- [synthesis.variant]
- [synthesis.tuple]
- [#synthesis.Reference]
- [synthesis.branch/get]
- [synthesis.function/apply]
- [#synthesis.Extension])
-
- (^ (synthesis.branch/case case))
- (/case.case! statement expression archive case)
-
- (^ (synthesis.branch/let let))
- (/case.let! statement expression archive let)
-
- (^ (synthesis.branch/if if))
- (/case.if! statement expression archive if)
-
- (^ (synthesis.loop/scope scope))
- (/loop.scope! statement expression archive scope)
-
- (^ (synthesis.loop/recur updates))
- (/loop.recur! statement expression archive updates)
-
- (^ (synthesis.function/abstraction abstraction))
- (//////phase\each _.return (/function.function statement expression archive abstraction))
- ))
-
(exception: .public cannot_recur_as_an_expression)
(def: (expression archive synthesis)
@@ -86,7 +53,7 @@
(//reference.reference /reference.system archive value)
(^ (synthesis.branch/case case))
- (/case.case ..statement expression archive case)
+ (/case.case ///extension/common.statement expression archive case)
(^ (synthesis.branch/let let))
(/case.let expression archive let)
@@ -98,13 +65,13 @@
(/case.get expression archive get)
(^ (synthesis.loop/scope scope))
- (/loop.scope ..statement expression archive scope)
+ (/loop.scope ///extension/common.statement expression archive scope)
(^ (synthesis.loop/recur updates))
(//////phase.except ..cannot_recur_as_an_expression [])
(^ (synthesis.function/abstraction abstraction))
- (/function.function ..statement expression archive abstraction)
+ (/function.function ///extension/common.statement expression archive abstraction)
(^ (synthesis.function/apply application))
(/function.apply expression archive application)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux
index 078cc797d..11a0b5640 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux
@@ -1,6 +1,6 @@
(.module:
[library
- [lux (#- function)
+ [lux (#- Variant Tuple function)
[abstract
["." monad (#+ do)]]
[data
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux
index 3788b7f6d..8b91f6d95 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux
@@ -1,6 +1,6 @@
(.module:
[library
- [lux #*
+ [lux (#- Variant Tuple)
[abstract
["." monad (#+ do)]]
[target