aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/source/lux.lux12
-rw-r--r--stdlib/source/lux/compiler/default/phase/analysis/expression.lux4
-rw-r--r--stdlib/source/lux/compiler/default/phase/extension.lux6
-rw-r--r--stdlib/source/lux/compiler/default/phase/extension/analysis/host.jvm.lux2
-rw-r--r--stdlib/source/lux/compiler/default/syntax.lux4
-rw-r--r--stdlib/source/lux/data/collection/list.lux12
-rw-r--r--stdlib/source/lux/data/format/json.lux21
-rw-r--r--stdlib/source/lux/data/text.lux47
-rw-r--r--stdlib/source/lux/data/text/regex.lux20
-rw-r--r--stdlib/source/lux/host.jvm.lux2
-rw-r--r--stdlib/test/test/lux/compiler/default/syntax.lux2
-rw-r--r--stdlib/test/test/lux/data/text/regex.lux6
12 files changed, 71 insertions, 67 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index 1b64aa22b..5ffe8d939 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -5154,17 +5154,7 @@
(def: (text/encode original)
(-> Text Text)
- (let [escaped (|> original
- (replace-all "\t" "\\t")
- (replace-all "\v" "\\v")
- (replace-all "\b" "\\b")
- (replace-all "\n" "\\n")
- (replace-all "\r" "\\r")
- (replace-all "\f" "\\f")
- (replace-all "\"" "\\\"")
- (replace-all "\\" "\\\\")
- )]
- ($_ text/compose "\"" escaped "\"")))
+ ($_ text/compose "\"" original "\""))
(do-template [<name> <extension> <doc>]
[(def: #export (<name> value)
diff --git a/stdlib/source/lux/compiler/default/phase/analysis/expression.lux b/stdlib/source/lux/compiler/default/phase/analysis/expression.lux
index ed2f81735..073cc9950 100644
--- a/stdlib/source/lux/compiler/default/phase/analysis/expression.lux
+++ b/stdlib/source/lux/compiler/default/phase/analysis/expression.lux
@@ -26,14 +26,14 @@
(exception: #export (macro-expansion-failed {macro Name} {inputs (List Code)} {error Text})
(ex.report ["Macro" (%name macro)]
["Inputs" (|> inputs
- (list/map (|>> %code (format "\n\t")))
+ (list/map (|>> %code (format "\n" text.tab)))
(text.join-with ""))]
["Error" error]))
(exception: #export (macro-call-must-have-single-expansion {macro Name} {inputs (List Code)})
(ex.report ["Macro" (%name macro)]
["Inputs" (|> inputs
- (list/map (|>> %code (format "\n\t")))
+ (list/map (|>> %code (format "\n" text.tab)))
(text.join-with ""))]))
(exception: #export (unrecognized-syntax {code Code})
diff --git a/stdlib/source/lux/compiler/default/phase/extension.lux b/stdlib/source/lux/compiler/default/phase/extension.lux
index 38ca02700..c7a2048a8 100644
--- a/stdlib/source/lux/compiler/default/phase/extension.lux
+++ b/stdlib/source/lux/compiler/default/phase/extension.lux
@@ -49,7 +49,7 @@
["Available" (|> bundle
dictionary.keys
(list.sort text/<)
- (list/map (|>> %t (format "\n\t")))
+ (list/map (|>> %t (format "\n" text.tab)))
(text.join-with ""))]))
(exception: #export (incorrect-arity {name Text} {arity Nat} {args Nat})
@@ -75,7 +75,9 @@
(ex.throw unknown [where name bundle])
(#.Some handler)
- ((handler name phase) parameters stateE))))
+ ((<| (//.timed (name-of ..apply) (%t name))
+ ((handler name phase) parameters))
+ stateE))))
(def: #export (localized get set transform)
(All [s s' i o v]
diff --git a/stdlib/source/lux/compiler/default/phase/extension/analysis/host.jvm.lux b/stdlib/source/lux/compiler/default/phase/extension/analysis/host.jvm.lux
index 5406ac20a..31f4b33ff 100644
--- a/stdlib/source/lux/compiler/default/phase/extension/analysis/host.jvm.lux
+++ b/stdlib/source/lux/compiler/default/phase/extension/analysis/host.jvm.lux
@@ -95,7 +95,7 @@
(ex.report ["Class" class]
["Method" method]
["Hints" (|> hints
- (list/map (|>> product.left %type (format "\n\t")))
+ (list/map (|>> product.left %type (format "\n" text.tab)))
(text.join-with ""))]))]
[no-candidates]
diff --git a/stdlib/source/lux/compiler/default/syntax.lux b/stdlib/source/lux/compiler/default/syntax.lux
index f333917d8..2aaa46992 100644
--- a/stdlib/source/lux/compiler/default/syntax.lux
+++ b/stdlib/source/lux/compiler/default/syntax.lux
@@ -140,7 +140,6 @@
[code l.any]
(case code
## Handle special cases.
- "t" (wrap [2 "\t"])
"v" (wrap [2 "\v"])
"b" (wrap [2 "\b"])
"n" (wrap [2 ..new-line])
@@ -624,8 +623,7 @@
(^template [<input> <output>]
(^ (char <input>))
(!find-next-escape 2 next-escape end source-code total <output>))
- (["t" "\t"]
- ["v" "\v"]
+ (["v" "\v"]
["b" "\b"]
["n" (static ..new-line)]
["r" "\r"]
diff --git a/stdlib/source/lux/data/collection/list.lux b/stdlib/source/lux/data/collection/list.lux
index ef1ebf5ac..c49a7ba9f 100644
--- a/stdlib/source/lux/data/collection/list.lux
+++ b/stdlib/source/lux/data/collection/list.lux
@@ -435,8 +435,8 @@
(identifier$ ("lux text concat" base "'"))]))))
pattern (` [(~+ (map (function (_ [v vs]) (` (#.Cons (~ v) (~ vs))))
vars+lists))])
- g!step (identifier$ "\tstep\t")
- g!blank (identifier$ "\t_\t")
+ g!step (identifier$ "0step0")
+ g!blank (identifier$ "0_0")
list-vars (map product.right vars+lists)
code (` (: (~ zip-type)
(function ((~ g!step) (~+ list-vars))
@@ -466,8 +466,8 @@
(if (n/> 0 num-lists)
(let [(^open ".") Functor<List>
indices (..indices num-lists)
- g!return-type (identifier$ "\treturn-type\t")
- g!func (identifier$ "\tfunc\t")
+ g!return-type (identifier$ "0return-type0")
+ g!func (identifier$ "0func0")
type-vars (: (List Code) (map (|>> nat/encode identifier$) indices))
zip-type (` (All [(~+ type-vars) (~ g!return-type)]
(-> (-> (~+ type-vars) (~ g!return-type))
@@ -482,8 +482,8 @@
(identifier$ ("lux text concat" base "'"))]))))
pattern (` [(~+ (map (function (_ [v vs]) (` (#.Cons (~ v) (~ vs))))
vars+lists))])
- g!step (identifier$ "\tstep\t")
- g!blank (identifier$ "\t_\t")
+ g!step (identifier$ "0step0")
+ g!blank (identifier$ "0_0")
list-vars (map product.right vars+lists)
code (` (: (~ zip-type)
(function ((~ g!step) (~ g!func) (~+ list-vars))
diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux
index c26df1893..1d0837b90 100644
--- a/stdlib/source/lux/data/format/json.lux
+++ b/stdlib/source/lux/data/format/json.lux
@@ -452,13 +452,20 @@
(def: escaped~
(l.Lexer Text)
($_ p.either
- (p.after (l.this "\\t") (parser/wrap "\t"))
- (p.after (l.this "\\b") (parser/wrap "\b"))
- (p.after (l.this "\\n") (parser/wrap "\n"))
- (p.after (l.this "\\r") (parser/wrap "\r"))
- (p.after (l.this "\\f") (parser/wrap "\f"))
- (p.after (l.this "\\\"") (parser/wrap "\""))
- (p.after (l.this "\\\\") (parser/wrap "\\"))))
+ (p.after (l.this "\\t")
+ (parser/wrap text.tab))
+ (p.after (l.this "\\b")
+ (parser/wrap text.back-space))
+ (p.after (l.this "\\n")
+ (parser/wrap text.new-line))
+ (p.after (l.this "\\r")
+ (parser/wrap text.carriage-return))
+ (p.after (l.this "\\f")
+ (parser/wrap text.form-feed))
+ (p.after (l.this (text/compose "\\" text.double-quote))
+ (parser/wrap text.double-quote))
+ (p.after (l.this "\\\\")
+ (parser/wrap "\\"))))
(def: string~
(l.Lexer String)
diff --git a/stdlib/source/lux/data/text.lux b/stdlib/source/lux/data/text.lux
index 48f35febe..0c6a5ea45 100644
--- a/stdlib/source/lux/data/text.lux
+++ b/stdlib/source/lux/data/text.lux
@@ -216,30 +216,37 @@
(-> Text Text Text)
(enclose [boundary boundary] content))
-(def: #export encode
- (-> Text Text)
- (|>> (replace-all "\\" "\\\\")
- (replace-all "\t" "\\t")
- (replace-all "\v" "\\v")
- (replace-all "\b" "\\b")
- (replace-all "\n" "\\n")
- (replace-all "\r" "\\r")
- (replace-all "\f" "\\f")
- (replace-all "\"" "\\\"")
- (..enclose' "\"")))
-
(def: #export from-code
(-> Nat Text)
(|>> (:coerce Int) "lux int char"))
+(do-template [<name> <code>]
+ [(def: #export <name> (from-code <code>))]
+
+ [back-space 8]
+ [tab 9]
+ [new-line 10]
+ [vertical-tab 11]
+ [form-feed 12]
+ [carriage-return 13]
+ [double-quote 34]
+ )
+
+(def: #export encode
+ (-> Text Text)
+ (..enclose' ..double-quote))
+
(def: #export (space? char)
{#.doc "Checks whether the character is white-space."}
(-> Nat Bit)
- (case char
- (^or (^ (char "\t")) (^ (char "\v"))
- (^ (char " ")) (^ (char "\n"))
- (^ (char "\r")) (^ (char "\f")))
- #1
-
- _
- #0))
+ (`` (case char
+ (^or (^ (char (~~ (static ..tab))))
+ (^ (char (~~ (static ..vertical-tab))))
+ (^ (char " "))
+ (^ (char (~~ (static ..new-line))))
+ (^ (char (~~ (static ..carriage-return))))
+ (^ (char (~~ (static ..form-feed)))))
+ #1
+
+ _
+ #0)))
diff --git a/stdlib/source/lux/data/text/regex.lux b/stdlib/source/lux/data/text/regex.lux
index ffd937d8e..a5409438e 100644
--- a/stdlib/source/lux/data/text/regex.lux
+++ b/stdlib/source/lux/data/text/regex.lux
@@ -8,14 +8,14 @@
["e" error]
["." maybe]
["." number ("int/." Codec<Text,Int>)]
- ["." text
- ["l" lexer]
- format]
[collection
["." list ("list/." Fold<List> Monad<List>)]]]
["." macro (#+ with-gensyms)
["." code]
- ["s" syntax (#+ syntax:)]]])
+ ["s" syntax (#+ syntax:)]]]
+ ["." //
+ ["l" lexer]
+ format])
## [Utils]
(def: regex-char^
@@ -50,7 +50,7 @@
(-> (l.Lexer (List Text)) (l.Lexer Text))
(do p.Monad<Parser>
[parts part^]
- (wrap (text.join-with "" parts))))
+ (wrap (//.join-with "" parts))))
(def: name-char^
(l.Lexer Text)
@@ -81,9 +81,9 @@
(def: re-range^
(l.Lexer Code)
(do p.Monad<Parser>
- [from (|> regex-char^ (:: @ map (|>> (text.nth 0) maybe.assume)))
+ [from (|> regex-char^ (:: @ map (|>> (//.nth 0) maybe.assume)))
_ (l.this "-")
- to (|> regex-char^ (:: @ map (|>> (text.nth 0) maybe.assume)))]
+ to (|> regex-char^ (:: @ map (|>> (//.nth 0) maybe.assume)))]
(wrap (` (l.range (~ (code.nat from)) (~ (code.nat to)))))))
(def: re-char^
@@ -122,7 +122,7 @@
(def: blank^
(l.Lexer Text)
- (l.one-of " \t"))
+ (l.one-of (format " " //.tab)))
(def: ascii^
(l.Lexer Text)
@@ -278,7 +278,7 @@
[idx
names
(list& (list g!temp complex
- (' #let) (` [(~ g!total) (:: (~! text.Monoid<Text>) (~' compose) (~ g!total) (~ g!temp))]))
+ (' #let) (` [(~ g!total) (:: (~! //.Monoid<Text>) (~' compose) (~ g!total) (~ g!temp))]))
steps)]
(#.Right [(#Capturing [?name num-captures]) scoped])
@@ -294,7 +294,7 @@
[idx!
(list& name! names)
(list& (list name! scoped
- (' #let) (` [(~ g!total) (:: (~! text.Monoid<Text>) (~' compose) (~ g!total) (~ access))]))
+ (' #let) (` [(~ g!total) (:: (~! //.Monoid<Text>) (~' compose) (~ g!total) (~ access))]))
steps)])
)))
[+0
diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux
index b7a55dfaa..9bb839aec 100644
--- a/stdlib/source/lux/host.jvm.lux
+++ b/stdlib/source/lux/host.jvm.lux
@@ -1088,7 +1088,7 @@
(def: (annotation$ [name params])
(-> Annotation JVM-Code)
- (format "(" name " " "{" (text.join-with "\t" (list/map annotation-param$ params)) "}" ")"))
+ (format "(" name " " "{" (text.join-with text.tab (list/map annotation-param$ params)) "}" ")"))
(def: (bound-kind$ kind)
(-> BoundKind JVM-Code)
diff --git a/stdlib/test/test/lux/compiler/default/syntax.lux b/stdlib/test/test/lux/compiler/default/syntax.lux
index 1bcb9dad8..6a447e9c1 100644
--- a/stdlib/test/test/lux/compiler/default/syntax.lux
+++ b/stdlib/test/test/lux/compiler/default/syntax.lux
@@ -30,7 +30,7 @@
(do r.Monad<Random>
[#let [digits "0123456789"
delimiters "()[]{}#.\""
- space "\t\v \n\r\f"
+ space "\v \n\r\f"
invalid-range (format digits delimiters space)
char-gen (|> r.nat
(:: @ map (|>> (n/% 256) (n/max 1)))
diff --git a/stdlib/test/test/lux/data/text/regex.lux b/stdlib/test/test/lux/data/text/regex.lux
index 96f56c3d9..7a6e88d33 100644
--- a/stdlib/test/test/lux/data/text/regex.lux
+++ b/stdlib/test/test/lux/data/text/regex.lux
@@ -5,7 +5,7 @@
pipe
["p" parser]]
[data
- [text ("text/." Equivalence<Text>)
+ ["." text ("text/." Equivalence<Text>)
format
["." lexer (#+ Lexer)]
["&" regex]]]
@@ -117,10 +117,10 @@
(and (should-pass (&.regex "\\p{OctDigit}") "6")
(should-fail (&.regex "\\p{OctDigit}") "."))
- (and (should-pass (&.regex "\\p{Blank}") "\t")
+ (and (should-pass (&.regex "\\p{Blank}") text.tab)
(should-fail (&.regex "\\p{Blank}") "."))
- (and (should-pass (&.regex "\\p{ASCII}") "\t")
+ (and (should-pass (&.regex "\\p{ASCII}") text.tab)
(should-fail (&.regex "\\p{ASCII}") "\u1234"))
(and (should-pass (&.regex "\\p{Contrl}") "\u0012")