
Uh, apologies. I got confused between reading your post and playing
for a while, and answered the wrong question.
/g
On 2/2/07, J. Garrett Morris
On 2/2/07, Chad Scherrer
wrote: So in reality, I'm trying to construct something like f :: (a -> STM b) -> STM (a -> b)
I just figured it was a general monadic kind of problem, more simply expressed using lists. But the (!!) solution doesn't make sense in this context.
Perhaps this will work for you:
f x = join . liftM f
This typechecks, and seems to work as expected, e.g.:
Prelude Control.Concurrent.STM Control.Monad> atomically (f readTVar (newTVar 'a')) 'a'
/g
-- It is myself I have never met, whose face is pasted on the underside of my mind.
-- It is myself I have never met, whose face is pasted on the underside of my mind.