aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/host.js.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/host.js.lux80
1 files changed, 11 insertions, 69 deletions
diff --git a/stdlib/source/lux/host.js.lux b/stdlib/source/lux/host.js.lux
index 7fd2a3420..ecca052e2 100644
--- a/stdlib/source/lux/host.js.lux
+++ b/stdlib/source/lux/host.js.lux
@@ -1,24 +1,25 @@
(.module:
[lux #*
- [abstract
- monad]
[control
["p" parser
["s" code (#+ Parser)]]]
[data
[collection
- ["." list #* ("#;." fold)]]]
+ ["." list ("#@." fold)]]]
+ [type
+ abstract]
[macro (#+ with-gensyms)
- ["." code]
- [syntax (#+ syntax:)]]])
+ [syntax (#+ syntax:)]
+ ["." code]]])
(template [<name> <type>]
- [(type: #export <name> (#.Primitive <type> #.Nil))]
+ [(abstract: #export <name> {} Any)]
- [Object "object"]
- [Function "function"]
- [Symbol "symbol"]
- [Undefined "undefined"]
+ [Object]
+ [Function]
+ [Symbol]
+ [Null]
+ [Undefined]
)
(template [<name> <type>]
@@ -28,62 +29,3 @@
[Number Frac]
[Boolean Bit]
)
-
-## [Syntax]
-(syntax: #export (set! field-name field-value object)
- {#.doc (doc "A way to set fields from objects."
- (set! "foo" +1234 some-object))}
- (wrap (list (` ("js set-field" (~ object) (~ field-name) (~ field-value))))))
-
-(syntax: #export (delete! field-name object)
- {#.doc (doc "A way to delete fields from objects."
- (delete! "foo" some-object))}
- (wrap (list (` ("js delete-field" (~ object) (~ field-name))))))
-
-(syntax: #export (get field-name type object)
- {#.doc (doc "A way to get fields from objects."
- (get "ceil" (ref "Math"))
- (get "ceil" (-> Frac Frac) (ref "Math")))}
- (wrap (list (` (:coerce (~ type)
- ("js get-field" (~ object) (~ field-name)))))))
-
-(syntax: #export (object {kvs (p.some (p.and s.any s.any))})
- {#.doc (doc "A way to create JavaScript objects."
- (object)
- (object "foo" foo "bar" (inc bar)))}
- (wrap (list (list;fold (function (_ [k v] object)
- (` (set! (~ k) (~ v) (~ object))))
- (` ("js object"))
- kvs))))
-
-(syntax: #export (ref {name s.text}
- {type (p.maybe s.any)})
- {#.doc (doc "A way to refer to JavaScript variables."
- (ref "document")
- (ref "Math.ceil" (-> Frac Frac)))}
- (wrap (list (` (:coerce (~ (default (' ..Object) type))
- ("js ref" (~ (code.text name))))))))
-
-(template [<name> <proc> <doc>]
- [(syntax: #export (<name>)
- {#.doc (doc <doc>
- (<name>))}
- (wrap (list (` (<proc>)))))]
-
- [null "js null" "Null object reference."]
- [undef "js undefined" "Undefined."]
- )
-
-(syntax: #export (call! {shape (p.or ($_ p.and s.any (s.tuple (p.some s.any)) (p.maybe s.any))
- ($_ p.and s.any s.text (s.tuple (p.some s.any)) (p.maybe s.any)))})
- {#.doc (doc "A way to call JavaScript functions and methods."
- (call! (ref "Math.ceil") [+123.45])
- (call! (ref "Math") "ceil" [+123.45]))}
- (case shape
- (#.Left [function args ?type])
- (wrap (list (` (:coerce (~ (default (' ..Object) ?type))
- ("js call" (~ function) (~+ args))))))
-
- (#.Right [object field args ?type])
- (wrap (list (` (:coerce (~ (default (' ..Object) ?type))
- ("js object-call" (~ object) (~ (code.text field)) (~+ args))))))))