[Haskell-cafe] Vector to Monadic Stream and back, how?

Roman Leshchinskiy rl at cse.unsw.edu.au
Wed Apr 14 05:37:22 EDT 2010

On 14/04/2010, at 09:05, Xiao-Yong Jin wrote:

> I want to use 'mapM' on Data.Vector.Vector, but it looks
> like the only 'mapM' defined is in
> Data.Vector.Fusion.Stream.Monadic.  I'm able to use 'stream'
> and 'liftStream' to convert a 'Vector' to a monadic stream,
> on which I can use 'mapM'.  But I couldn't find a way to
> convert the monadic stream back to Vector without using an
> intermediate list.  I don't think I understand the internal
> of monadic stream that much.  But it looks not so fusion to
> me.  Is it the only way back to Vector?

Unfortunately, it's not at all clear to me how to implement mapM on vectors/arrays without going through an intermediate list for arbitrary monads (it's easy for ST and IO). The next version of vector will include mapM and friends but it will probably be implemented much like you describe, with appropriate specialisations for ST and IO.


More information about the Haskell-Cafe mailing list