[Haskell-beginners] Using monad with arrow
Jarno Antikainen
jarno.antikainen at iki.fi
Mon Mar 1 06:31:33 EST 2010
Hello,
I have a function that returns its value in a monad, and I'd like to use that value in a function that returns an arrow, but I cannot figure out how to do that. The monad in this case is CouchMonad and the arrow is ArrowXml, but I guess that doesn't really matter.
For example, the function that returns its value in a monad:
toXNode :: String -> CouchMonad XNode
and a function that returns an arrow:
processReplacement :: (ArrowXml a) => String -> String -> a XmlTree XmlTree
In processReplacement I'd like to get a value from toXNode function, take it out from the monad and use the plain XNode value. Were it all simply CouchMonad, it would be something like this:
processReplacement elementId docId =
do
node <- toXNode docId
setNode node `when` idMatches elementId
But this is an arrow, so I need something different. I've read quite a few arrow articles and tutorials, but couldn't yet grasp how to do this and what is involved. Any ideas or pointers to examples?
Thanks!
BR,
Jarno
More information about the Beginners
mailing list