[Haskell-cafe] (a -> [b]) vs. [a -> b]

J. Garrett Morris trevion at gmail.com
Fri Feb 2 15:33:38 EST 2007


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 <trevion at gmail.com> wrote:
> 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.
>


-- 
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