aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/data/format/xml.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/data/format/xml.lux')
-rw-r--r--stdlib/source/library/lux/data/format/xml.lux39
1 files changed, 20 insertions, 19 deletions
diff --git a/stdlib/source/library/lux/data/format/xml.lux b/stdlib/source/library/lux/data/format/xml.lux
index 064476a7f..ef2c8e19a 100644
--- a/stdlib/source/library/lux/data/format/xml.lux
+++ b/stdlib/source/library/lux/data/format/xml.lux
@@ -35,8 +35,9 @@
(dictionary.empty name.hash))
(type: .public #rec XML
- (#Text Text)
- (#Node Tag Attrs (List XML)))
+ (Variant
+ (#Text Text)
+ (#Node Tag Attrs (List XML))))
(def: namespace_separator
":")
@@ -72,7 +73,7 @@
(def: xml_char^
(Parser Text)
- (<>.either (<text>.none_of ($_ text\compose "<>&" text.double_quote))
+ (<>.either (<text>.none_of ($_ text\composite "<>&" text.double_quote))
xml_escape_char^))
(def: xml_identifier
@@ -82,7 +83,7 @@
<text>.alpha)
tail (<text>.some (<>.either (<text>.one_of "_.-")
<text>.alpha_num))]
- (in ($_ text\compose head tail))))
+ (in ($_ text\composite head tail))))
(def: namespaced_symbol^
(Parser Name)
@@ -113,7 +114,7 @@
(def: attrs^
(Parser Attrs)
- (<| (\ <>.monad map (dictionary.of_list name.hash))
+ (<| (\ <>.monad each (dictionary.of_list name.hash))
<>.some
(<>.and (..spaced^ attr_name^))
(<>.after (<text>.this "="))
@@ -126,7 +127,7 @@
..spaced^
(<>.after (<text>.this "/"))
(<text>.enclosed ["<" ">"]))]
- (<>.assertion ($_ text\compose "Close tag does not match open tag." text.new_line
+ (<>.assertion ($_ text\composite "Close tag does not match open tag." text.new_line
"Expected: " (name\encoded expected) text.new_line
" Actual: " (name\encoded actual) text.new_line)
(name\= expected actual))))
@@ -157,7 +158,7 @@
(Parser XML)
(|> (..spaced^ (<text>.many xml_char^))
(<>.either cdata^)
- (<>\map (|>> #Text))))
+ (<>\each (|>> #Text))))
(def: null^
(Parser Any)
@@ -209,7 +210,7 @@
(-> Tag Text)
(case namespace
"" name
- _ ($_ text\compose namespace ..namespace_separator name)))
+ _ ($_ text\composite namespace ..namespace_separator name)))
(def: .public attribute
(-> Attribute Text)
@@ -219,8 +220,8 @@
Text
(let [quote (: (-> Text Text)
(function (_ value)
- ($_ text\compose text.double_quote value text.double_quote)))]
- ($_ text\compose
+ ($_ text\composite text.double_quote value text.double_quote)))]
+ ($_ text\composite
"<?xml"
" version=" (quote "1.0")
" encoding=" (quote "UTF-8")
@@ -234,11 +235,11 @@
(function (_ attrs)
(|> attrs
dictionary.entries
- (list\map (function (_ [key value])
- ($_ text\compose (..attribute key) "=" text.double_quote (sanitize_value value) text.double_quote)))
+ (list\each (function (_ [key value])
+ ($_ text\composite (..attribute key) "=" text.double_quote (sanitize_value value) text.double_quote)))
(text.interposed " "))))]
(function (_ input)
- ($_ text\compose
+ ($_ text\composite
..xml_header text.new_line
(loop [prefix ""
input input]
@@ -250,8 +251,8 @@
(let [tag (..tag xml_tag)
attrs (if (dictionary.empty? xml_attrs)
""
- ($_ text\compose " " (attributes xml_attrs)))]
- ($_ text\compose
+ ($_ text\composite " " (attributes xml_attrs)))]
+ ($_ text\composite
prefix "<" tag attrs ">"
(sanitize_value value)
"</" tag ">"))
@@ -260,12 +261,12 @@
(let [tag (..tag xml_tag)
attrs (if (dictionary.empty? xml_attrs)
""
- ($_ text\compose " " (attributes xml_attrs)))]
+ ($_ text\composite " " (attributes xml_attrs)))]
(if (list.empty? xml_children)
- ($_ text\compose prefix "<" tag attrs "/>")
- ($_ text\compose prefix "<" tag attrs ">"
+ ($_ text\composite prefix "<" tag attrs "/>")
+ ($_ text\composite prefix "<" tag attrs ">"
(|> xml_children
- (list\map (|>> (recur (text\compose prefix text.tab)) (text\compose text.new_line)))
+ (list\each (|>> (recur (text\composite prefix text.tab)) (text\composite text.new_line)))
text.together)
text.new_line prefix "</" tag ">")))))
))))