On Apr 28, 2009, at 01:43 , aditya siram wrote:
I want to be able to use these accessors like so:
> doSomethingWithA mySTM = do
> case (getA mySTM) of
> 1 -> doStuff
> 0 -> doSomethingElse
But getA returns an STM Int, so I still have to do a :
> doSomethingWithA = do
> a' <- (getA mySTM)
> case a' of
> 1 -> doStuff
> 0 -> doSomethingElse
This doesn't really save me a lot of boilerplate. What is the best way of writing a function that just returns my values do I can work with them in the STM monad without unpacking them all the time?
Lift your operation into STM with fmap/liftM instead?