Construct HXT arrow that selects multiple Maybe values

115 Views Asked by At

I'm confused with HXT arrows API. Similarly to the list monad, any arrow that produces no result will determine result of [] and match will become element in one dimension of Cartesian product of all matches.

I have XML file with a nested optional elements like this:

<root>
 ...
 <b>
  <x>1</x>
  <y>2</y>
  ...
 </b>
 <x>3</x>
 <y>4</y>
 ...
</root>

How can I construct an arrow that will traverse this tree once and produce result in fixed structure similar to one below? I care only about small part of the structure.

[(Just 1, Just 2), (Just 3, Just 4)] :: [(Maybe a, Maybe b), (Maybe a, Maybe b)]

or

[(Nothing, Nothing), (Just 3, Just 4)] :: [(Maybe a, Maybe b), (Maybe a, Maybe b)]
0

There are 0 best solutions below