
On Fri, Apr 16, 2010 at 11:19 PM, Roman Leshchinskiy
That said, it would be quite possible to provide something like the following:
fold_inplace :: Vector v a => (v a -> b -> v a) -> v a -> [b] -> v a
as far as i understand there would be two ways of writing such a function : 1) to use mutable vectors monadically underneath and hide them inside some kind of unsafeX, or 2) to give a specialized fold with sufficient hints to the compiler to use the rewriting framework. i attempted to start 1, but it seems like this function can not have an entirely pure interface and still avoid copying. more specifically, the signature for the update function (v a -> b -> v a) seems like it necessarily creates a copy, unless i misunderstand? wouldn't you need some kind of monadic update function (v a -> b -> m () ) which modifies the vector in place?
This could use the recycling framework to safely do as much in-place as possible while still preserving a purely functional interface. I have to think about it. Really, this looks like just a poor man's substitute for linear types.
although i am supposed to know something about category theory, since my training is in math, i don't know about girard's later work. is there a short precis you can give (or a pointer?) thanks and best regards, ben