aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/source/lux/compiler/default/phase/synthesis.lux3
-rw-r--r--stdlib/source/lux/compiler/default/phase/translation.lux15
-rw-r--r--stdlib/source/lux/data/text/unicode.lux16
-rw-r--r--stdlib/source/lux/math/random.lux25
4 files changed, 42 insertions, 17 deletions
diff --git a/stdlib/source/lux/compiler/default/phase/synthesis.lux b/stdlib/source/lux/compiler/default/phase/synthesis.lux
index 99111d2a7..2ee018be4 100644
--- a/stdlib/source/lux/compiler/default/phase/synthesis.lux
+++ b/stdlib/source/lux/compiler/default/phase/synthesis.lux
@@ -32,7 +32,7 @@
(type: #export Primitive
(#Bit Bit)
- (#I64 I64)
+ (#I64 (I64 Any))
(#F64 Frac)
(#Text Text))
@@ -151,6 +151,7 @@
[(template: #export (<name> content)
(<tag> content))]
+ [path/bind #..Bind]
[path/alt #..Alt]
[path/seq #..Seq]
[path/then #..Then]
diff --git a/stdlib/source/lux/compiler/default/phase/translation.lux b/stdlib/source/lux/compiler/default/phase/translation.lux
index e79645e63..d8a58ca84 100644
--- a/stdlib/source/lux/compiler/default/phase/translation.lux
+++ b/stdlib/source/lux/compiler/default/phase/translation.lux
@@ -56,7 +56,9 @@
(: (-> Text expression (Error Any))
evaluate!)
(: (-> Text statement (Error Any))
- execute!))
+ execute!)
+ (: (-> Name expression (Error Any))
+ define!))
(type: #export (Buffer statement) (Row [Name statement]))
@@ -194,6 +196,17 @@
[execute! statement]
)
+(def: #export (define! name code)
+ (All [anchor expression statement]
+ (-> Name expression (Operation anchor expression statement Any)))
+ (function (_ (^@ stateE [bundle state]))
+ (case (:: (get@ #host state) define! name code)
+ (#error.Error error)
+ (ex.throw cannot-interpret error)
+
+ (#error.Success output)
+ (#error.Success [stateE output]))))
+
(def: #export (save! name code)
(All [anchor expression statement]
(-> Name statement (Operation anchor expression statement Any)))
diff --git a/stdlib/source/lux/data/text/unicode.lux b/stdlib/source/lux/data/text/unicode.lux
index ebd54c02b..4cc1f66bc 100644
--- a/stdlib/source/lux/data/text/unicode.lux
+++ b/stdlib/source/lux/data/text/unicode.lux
@@ -59,6 +59,7 @@
(do-template [<name> <start> <end>]
[(def: #export <name> Segment (..segment (hex <start>) (hex <end>)))]
+ ## Normal segments
[basic-latin "0000" "007F"]
[latin-1-supplement "00A0" "00FF"]
[latin-extended-a "0100" "017F"]
@@ -181,6 +182,10 @@
[cjk-unified-ideographs-extension-b "20000" "2A6DF"]
[cjk-compatibility-ideographs-supplement "2F800" "2FA1F"]
[tags "E0000" "E007F"]
+
+ ## Specialized segments
+ [basic-latin/upper-alpha "0041" "005A"]
+ [basic-latin/lower-alpha "0061" "007A"]
)
(type: #export Set (Tree Segment []))
@@ -342,6 +347,11 @@
Set
(finger.branch (set half/0) (set half/1)))
-(def: #export ascii
- Set
- (set (list basic-latin)))
+(do-template [<name> <segments>]
+ [(def: #export <name> Set (set <segments>))]
+
+ [ascii (list basic-latin)]
+ [ascii/alpha (list basic-latin/upper-alpha basic-latin/lower-alpha)]
+ [ascii/upper-alpha (list basic-latin/upper-alpha)]
+ [ascii/lower-alpha (list basic-latin/lower-alpha)]
+ )
diff --git a/stdlib/source/lux/math/random.lux b/stdlib/source/lux/math/random.lux
index e441fc0f2..826846aac 100644
--- a/stdlib/source/lux/math/random.lux
+++ b/stdlib/source/lux/math/random.lux
@@ -99,17 +99,15 @@
(i64.left-shift 32)
("lux i64 +" right))])))
-(def: #export nat
- (Random Nat)
- (:: Monad<Random> map .nat ..i64))
-
-(def: #export int
- (Random Int)
- (:: Monad<Random> map .int ..i64))
+(do-template [<name> <type> <cast>]
+ [(def: #export <name>
+ (Random <type>)
+ (:: Monad<Random> map <cast> ..i64))]
-(def: #export rev
- (Random Rev)
- (:: Monad<Random> map .rev ..i64))
+ [nat Nat .nat]
+ [int Int .int]
+ [rev Rev .rev]
+ )
(def: #export frac
(Random Frac)
@@ -143,8 +141,11 @@
(-> Nat (Random Text))
(text (char <set>)))]
- [unicode unicode.full]
- [ascii unicode.ascii]
+ [unicode unicode.full]
+ [ascii unicode.ascii]
+ [ascii/alpha unicode.ascii/alpha]
+ [ascii/upper-alpha unicode.ascii/upper-alpha]
+ [ascii/lower-alpha unicode.ascii/lower-alpha]
)
(do-template [<name> <type> <ctor> <gen>]