aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/data/text/buffer.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/data/text/buffer.lux')
-rw-r--r--stdlib/source/library/lux/data/text/buffer.lux138
1 files changed, 68 insertions, 70 deletions
diff --git a/stdlib/source/library/lux/data/text/buffer.lux b/stdlib/source/library/lux/data/text/buffer.lux
index 828a4772e..af3341930 100644
--- a/stdlib/source/library/lux/data/text/buffer.lux
+++ b/stdlib/source/library/lux/data/text/buffer.lux
@@ -48,8 +48,6 @@
(as_is))))
(`` (abstract: .public Buffer
- {}
-
(for {@.old [Nat (-> java/lang/StringBuilder java/lang/StringBuilder)]
@.jvm [Nat (-> java/lang/StringBuilder java/lang/StringBuilder)]
@.js [Nat (-> (JS_Array Text) (JS_Array Text))]
@@ -57,79 +55,79 @@
... default
(Row Text))
- (def: .public empty
- Buffer
- (:abstraction (with_expansions [<jvm> [0 function.identity]]
- (for {@.old <jvm>
- @.jvm <jvm>
- @.js [0 function.identity]
- @.lua [0 function.identity]}
- ... default
- row.empty))))
+ [(def: .public empty
+ Buffer
+ (:abstraction (with_expansions [<jvm> [0 function.identity]]
+ (for {@.old <jvm>
+ @.jvm <jvm>
+ @.js [0 function.identity]
+ @.lua [0 function.identity]}
+ ... default
+ row.empty))))
- (def: .public (then chunk buffer)
- (-> Text Buffer Buffer)
- (with_expansions [<jvm> (let [[capacity transform] (:representation buffer)
- then! (: (-> Text java/lang/StringBuilder java/lang/StringBuilder)
- (function (_ chunk builder)
- (exec
- (java/lang/Appendable::append (:as java/lang/CharSequence chunk)
- builder)
- builder)))]
- (:abstraction [(n.+ (//.size chunk) capacity)
- (|>> transform (then! chunk))]))]
- (for {@.old <jvm>
- @.jvm <jvm>
- @.js (let [[capacity transform] (:representation buffer)
- then! (: (-> (JS_Array Text) (JS_Array Text))
- (function (_ array)
- (exec
- (JS_Array::push [chunk] array)
- array)))]
- (:abstraction [(n.+ (//.size chunk) capacity)
- (|>> transform then!)]))
- @.lua (let [[capacity transform] (:representation buffer)
- then! (: (-> (array.Array Text) (array.Array Text))
+ (def: .public (then chunk buffer)
+ (-> Text Buffer Buffer)
+ (with_expansions [<jvm> (let [[capacity transform] (:representation buffer)
+ then! (: (-> Text java/lang/StringBuilder java/lang/StringBuilder)
+ (function (_ chunk builder)
+ (exec
+ (java/lang/Appendable::append (:as java/lang/CharSequence chunk)
+ builder)
+ builder)))]
+ (:abstraction [(n.+ (//.size chunk) capacity)
+ (|>> transform (then! chunk))]))]
+ (for {@.old <jvm>
+ @.jvm <jvm>
+ @.js (let [[capacity transform] (:representation buffer)
+ then! (: (-> (JS_Array Text) (JS_Array Text))
(function (_ array)
(exec
- (table/insert [array chunk])
+ (JS_Array::push [chunk] array)
array)))]
(:abstraction [(n.+ (//.size chunk) capacity)
- (|>> transform then!)]))}
- ... default
- (|> buffer :representation (row.suffix chunk) :abstraction))))
+ (|>> transform then!)]))
+ @.lua (let [[capacity transform] (:representation buffer)
+ then! (: (-> (array.Array Text) (array.Array Text))
+ (function (_ array)
+ (exec
+ (table/insert [array chunk])
+ array)))]
+ (:abstraction [(n.+ (//.size chunk) capacity)
+ (|>> transform then!)]))}
+ ... default
+ (|> buffer :representation (row.suffix chunk) :abstraction))))
- (def: .public size
- (-> Buffer Nat)
- (with_expansions [<jvm> (|>> :representation product.left)]
- (for {@.old <jvm>
- @.jvm <jvm>
- @.js <jvm>
- @.lua <jvm>}
- ... default
- (|>> :representation
- (row\mix (function (_ chunk total)
- (n.+ (//.size chunk) total))
- 0)))))
+ (def: .public size
+ (-> Buffer Nat)
+ (with_expansions [<jvm> (|>> :representation product.left)]
+ (for {@.old <jvm>
+ @.jvm <jvm>
+ @.js <jvm>
+ @.lua <jvm>}
+ ... default
+ (|>> :representation
+ (row\mix (function (_ chunk total)
+ (n.+ (//.size chunk) total))
+ 0)))))
- (def: .public (text buffer)
- (-> Buffer Text)
- (with_expansions [<jvm> (let [[capacity transform] (:representation buffer)]
- (|> (java/lang/StringBuilder::new (.int capacity))
- transform
- java/lang/StringBuilder::toString))]
- (for {@.old <jvm>
- @.jvm <jvm>
- @.js (let [[capacity transform] (:representation buffer)]
- (|> (array.empty 0)
- (:as (JS_Array Text))
- transform
- (JS_Array::join [""])))
- @.lua (let [[capacity transform] (:representation buffer)]
- (table/concat [(transform (array.empty 0)) ""]))}
- ... default
- (row\mix (function (_ chunk total)
- (format total chunk))
- ""
- (:representation buffer)))))
+ (def: .public (text buffer)
+ (-> Buffer Text)
+ (with_expansions [<jvm> (let [[capacity transform] (:representation buffer)]
+ (|> (java/lang/StringBuilder::new (.int capacity))
+ transform
+ java/lang/StringBuilder::toString))]
+ (for {@.old <jvm>
+ @.jvm <jvm>
+ @.js (let [[capacity transform] (:representation buffer)]
+ (|> (array.empty 0)
+ (:as (JS_Array Text))
+ transform
+ (JS_Array::join [""])))
+ @.lua (let [[capacity transform] (:representation buffer)]
+ (table/concat [(transform (array.empty 0)) ""]))}
+ ... default
+ (row\mix (function (_ chunk total)
+ (format total chunk))
+ ""
+ (:representation buffer)))))]
))