I am trying to learn Arrows in Haskell, so I am writing a simple application with the arrow based HXT library for XML. The examples in the HXT wikis and tutorials forgo function type signatures. However, I am quite fond of types and am trying to work out how to use them. This is where I have met a stumbling block. Given these functions:
readXml str = runX (readString [withValidate no] str)
atTag tag = deep (isElem >>> hasName tag)
I figure they should be assigned the following signatures:
readXml ∷ String → IO [XmlTree]
atTag ∷ ArrowXml a ⇒ String → a XmlTree XmlTree
I am trying to hook these together using arrow syntax as such:
parseItem = proc str -> do
desc <- text <<< atTag "description" <<< arr readXml -< str
...
However, if my my type-signatures are correct (GHC hasn't complained), I would need a way in which to combine monad syntax and arrow syntax to get the XmlTree
out of and returned to IO
.
I am unsure how to proceed. Anyone have any insights?