[Haskell-cafe] Vector to Monadic Stream and back, how?
xj2106 at columbia.edu
Wed Apr 14 10:53:24 EDT 2010
On Wed, 14 Apr 2010 19:37:22 +1000, Roman Leshchinskiy wrote:
> 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.
Thanks for the reply. I am using it for 'Either a', but I
guess the performance wouldn't be worse than 'mapM' on an
Array. I am OK with it.
J c/* __o/*
X <\ * (__
Y */\ <
More information about the Haskell-Cafe