aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/macro/code.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/macro/code.lux')
-rw-r--r--stdlib/source/lux/macro/code.lux27
1 files changed, 16 insertions, 11 deletions
diff --git a/stdlib/source/lux/macro/code.lux b/stdlib/source/lux/macro/code.lux
index 219bb76e4..8b868db58 100644
--- a/stdlib/source/lux/macro/code.lux
+++ b/stdlib/source/lux/macro/code.lux
@@ -10,9 +10,9 @@
["." int]
["." rev]
["." frac]]
- ["." text ("#@." monoid)]
+ ["." text ("#@." monoid equivalence)]
[collection
- ["." list ("#@." functor)]]]])
+ ["." list ("#@." functor fold)]]]])
## (type: (Code' w)
## (#.Bit Bit)
@@ -109,10 +109,13 @@
[_ (<tag> members)]
($_ text@compose
<open>
- (|> members
- (list@map to-text)
- (list.interpose " ")
- (text.join-with ""))
+ (list@fold (function (_ next prev)
+ (let [next (to-text next)]
+ (if (text@= "" prev)
+ next
+ ($_ text@compose prev " " next))))
+ ""
+ members)
<close>))
([#.Form "(" ")"]
[#.Tuple "[" "]"])
@@ -120,11 +123,13 @@
[_ (#.Record pairs)]
($_ text@compose
"{"
- (|> pairs
- (list@map (function (_ [left right])
- ($_ text@compose (to-text left) " " (to-text right))))
- (list.interpose " ")
- (text.join-with ""))
+ (list@fold (function (_ [left right] prev)
+ (let [next ($_ text@compose (to-text left) " " (to-text right))]
+ (if (text@= "" prev)
+ next
+ ($_ text@compose prev " " next))))
+ ""
+ pairs)
"}")
))