[Haskell-beginners] Using monad with arrow

Stephen Tetley stephen.tetley at gmail.com
Mon Mar 1 08:25:20 EST 2010

Hi Jarno

A cursory look at the CouchMonad says it is build upon the IO monad so
you won't be able to safely extract values out of it. This suggests
that you should "run" HXT functions within the CouchMonad monad.

The HXT library has various run_ functions - runIOLA, runSt, ... - to
run a computation and produce a value. I don't know the HXT library,
so don't know which particular run function to use, but a viable
construction might look like one of these two:

 processReplacement elementId docId state0 =
     node <- toXNode docId
     let ans = runSt (setNode node `when` idMatches elementId) state0
     return ans

Or maybe runIOLA:

 processReplacement elementId docId =
     node <- toXNode docId
     ans <- runIOLA (setNode node `when` idMatches elementId)
     return ans

Best wishes


More information about the Beginners mailing list