[Haskell-cafe] replicateM over vectors

2010-04-01 Thread Scherrer, Chad
Hi, I'd like to be able to do replicateM, but over a vector instead of a list. Right now I'm doing this: import qualified Data.Vector.Generic as G import qualified Data.Vector.Unboxed.Mutable as M replicateM n action = do mu - M.unsafeNew n let go !i | i n = action = M.unsafeWrite mu i

Re: [Haskell-cafe] replicateM over vectors

2010-04-01 Thread Don Stewart
Chad.Scherrer: Hi, I'd like to be able to do replicateM, but over a vector instead of a list. Right now I'm doing this: import qualified Data.Vector.Generic as G import qualified Data.Vector.Unboxed.Mutable as M replicateM n action = do mu - M.unsafeNew n let go !i | i n =

Re: [Haskell-cafe] replicateM over vectors

2010-04-01 Thread Roman Leshchinskiy
On 02/04/2010, at 12:16, Don Stewart wrote: Chad.Scherrer: Hi, I'd like to be able to do replicateM, but over a vector instead of a list. Right now I'm doing this: The operation you are looking for is called newWith. It probably should be called replicate. Roman? Can we generate frozen

Re: [Haskell-cafe] replicateM over vectors

2010-04-01 Thread Don Stewart
rl: replicate :: Int - a - New a replicate n x = Generic.New.unstream (Fusion.Stream.replicate n x) and then either Mutable.run (replicate n x) to get a mutable vector or new (replicate n x) Hmm, but here 'a' is pure. I don't think he wants newWith :: (PrimMonad m, MVector

Re: [Haskell-cafe] replicateM over vectors

2010-04-01 Thread Roman Leshchinskiy
On 02/04/2010, at 13:01, Don Stewart wrote: rl: replicate :: Int - a - New a replicate n x = Generic.New.unstream (Fusion.Stream.replicate n x) and then either Mutable.run (replicate n x) to get a mutable vector or new (replicate n x) Hmm, but here 'a' is pure. I don't