Xml decoder module sharing the spirit of Json.Decode.Extra.
Uses (|:) infix operator that allows writing decoders in sequential style like so:
import Xml.Decode exposing (Decoder, succeed, path, single, list, string, int)
applicativeDecoder : Decoder ( String, List Int )
applicativeDecoder =
succeed (,)
|: path [ "path", "to", "string", "value" ] (single string)
|: path [ "path", "to", "int", "values" ] (list int)
Xml.Decode.run applicativeDecoder
"""
<root>
<path>
<to>
<string>
<value>SomeString</value>
</string>
<int>
<values>1</values>
<values>2</values>
</int>
</to>
</path>
</root>
"""
--> Ok ( "SomeString", [ 1, 2 ] )Benefit of this style is it leverages standard decoders from Xml.Decode,
so you only have to import (|:).
Also, this style can be considered "Applicative" style of sequential application.
(|:) is essentially Applicative's (<*>).
Equivalent to Json.Decode.Extra.(|:), infix version of andMap.
Equivalent to
Json.Decode.Extra.andMap, allows writing XML decoders in sequential style.