[Haskell-cafe] (a -> [b]) vs. [a -> b]
J. Garrett Morris
trevion at gmail.com
Fri Feb 2 15:28:05 EST 2007
On 2/2/07, Chad Scherrer <chad.scherrer at gmail.com> 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.
More information about the Haskell-Cafe
mailing list