aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux.lux4
-rw-r--r--stdlib/source/lux/control/exception.lux2
-rw-r--r--stdlib/source/lux/control/parser/text.lux2
-rw-r--r--stdlib/source/lux/data/text.lux13
-rw-r--r--stdlib/source/lux/target/jvm/type.lux13
-rw-r--r--stdlib/source/lux/target/jvm/type/descriptor.lux5
-rw-r--r--stdlib/source/test/lux/data/text.lux2
7 files changed, 22 insertions, 19 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index b2deead45..0b8941ba7 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -3764,7 +3764,7 @@
(def: (split! at x)
(-> Nat Text [Text Text])
[("lux text clip" 0 at x)
- ("lux text clip" at ("lux i64 -" at ("lux text size" x)) x)])
+ ("lux text clip" at (|> x "lux text size" ("lux i64 -" at)) x)])
(def: (split_with token sample)
(-> Text Text (Maybe [Text Text]))
@@ -3844,7 +3844,7 @@
list\reverse
(interpose ..module_separator)
(text\join_with ""))
- clean ("lux text clip" relatives ("lux i64 -" relatives ("lux text size" module)) module)
+ clean ("lux text clip" relatives (|> module "lux text size" ("lux i64 -" relatives)) module)
output (case ("lux text size" clean)
0 prefix
_ ($_ text\compose prefix ..module_separator clean))]
diff --git a/stdlib/source/lux/control/exception.lux b/stdlib/source/lux/control/exception.lux
index fdac9ca3c..0f5f62aa3 100644
--- a/stdlib/source/lux/control/exception.lux
+++ b/stdlib/source/lux/control/exception.lux
@@ -49,7 +49,7 @@
(let [reference (get@ #label exception)]
(if (text.starts_with? reference error)
(#//.Success (|> error
- (text.clip (text.size reference) (text.size error))
+ (text.clip' (text.size reference))
maybe.assume
then))
(#//.Failure error)))))
diff --git a/stdlib/source/lux/control/parser/text.lux b/stdlib/source/lux/control/parser/text.lux
index 8065e0794..7dc6001b5 100644
--- a/stdlib/source/lux/control/parser/text.lux
+++ b/stdlib/source/lux/control/parser/text.lux
@@ -359,7 +359,7 @@
(do //.monad
[[basis distance] parser]
(function (_ (^@ input [offset tape]))
- (case (/.clip basis ("lux i64 +" basis distance) tape)
+ (case (/.clip basis distance tape)
(#.Some output)
(#try.Success [input output])
diff --git a/stdlib/source/lux/data/text.lux b/stdlib/source/lux/data/text.lux
index 91d520c3c..45c986eca 100644
--- a/stdlib/source/lux/data/text.lux
+++ b/stdlib/source/lux/data/text.lux
@@ -121,18 +121,17 @@
_
false))
-(def: #export (clip from to input)
+(def: #export (clip offset characters input)
(-> Nat Nat Text (Maybe Text))
- (if (and (n.<= to from)
- (n.<= ("lux text size" input) to))
- (#.Some ("lux text clip" from (n.- from to) input))
+ (if (|> characters (n.+ offset) (n.<= ("lux text size" input)))
+ (#.Some ("lux text clip" offset characters input))
#.None))
-(def: #export (clip' from input)
+(def: #export (clip' offset input)
(-> Nat Text (Maybe Text))
(let [size ("lux text size" input)]
- (if (n.<= size from)
- (#.Some ("lux text clip" from (n.- from size) input))
+ (if (n.<= size offset)
+ (#.Some ("lux text clip" offset (n.- offset size) input))
#.None)))
(def: #export (split at x)
diff --git a/stdlib/source/lux/target/jvm/type.lux b/stdlib/source/lux/target/jvm/type.lux
index 3db4a584f..589b1201a 100644
--- a/stdlib/source/lux/target/jvm/type.lux
+++ b/stdlib/source/lux/target/jvm/type.lux
@@ -189,11 +189,14 @@
(let [repr (|> type ..descriptor /descriptor.descriptor)]
(if (and (text.starts_with? /descriptor.class_prefix repr)
(text.ends_with? /descriptor.class_suffix repr))
- (|> repr
- (text.clip (text.size /descriptor.class_prefix)
- (n.- (text.size /descriptor.class_suffix)
- (text.size repr)))
- (\ maybe.monad map (|>> //name.internal //name.external)))
+ (let [prefix_size (text.size /descriptor.class_prefix)
+ suffix_size (text.size /descriptor.class_suffix)
+ name_size (|> (text.size repr)
+ (n.- prefix_size)
+ (n.- suffix_size))]
+ (|> repr
+ (text.clip prefix_size name_size)
+ (\ maybe.monad map (|>> //name.internal //name.external))))
#.None)))
(def: #export format
diff --git a/stdlib/source/lux/target/jvm/type/descriptor.lux b/stdlib/source/lux/target/jvm/type/descriptor.lux
index fd511e780..983894ed4 100644
--- a/stdlib/source/lux/target/jvm/type/descriptor.lux
+++ b/stdlib/source/lux/target/jvm/type/descriptor.lux
@@ -114,8 +114,9 @@
(///name.internal repr)
(|> repr
(text.clip prefix_size
- (n.- suffix_size
- (text.size repr)))
+ (|> (text.size repr)
+ (n.- prefix_size)
+ (n.- suffix_size)))
(\ maybe.monad map ///name.internal)
maybe.assume))))))
)
diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux
index 8102ae30e..b5c9f433b 100644
--- a/stdlib/source/test/lux/data/text.lux
+++ b/stdlib/source/test/lux/data/text.lux
@@ -274,7 +274,7 @@
#0)))
(_.cover [/.clip /.clip']
(|> [(/.clip 0 sizeL sample)
- (/.clip sizeL (/.size sample) sample)
+ (/.clip sizeL (n.- sizeL (/.size sample)) sample)
(/.clip' sizeL sample)
(/.clip' 0 sample)]
(case> [(#.Right _l) (#.Right _r) (#.Right _r') (#.Right _f)]