[MLton] Monadic MLton.Vector.create with update

Stephen Weeks MLton@mlton.org
Thu, 30 Mar 2006 08:23:26 -0800


> You can write unfold_vec using the (non-monadic) create, but you need a ref
> cell to carry along the state (if you do it in the tabulator) or an initial
> value (if you do it in the final thunk).

Hmm, I wonder if create's tabulator function should also do a fold
:-).

> Note, your unfold_vec throws away the final state (the 'b returned in the
> tuple by the last call to the 'b -> 'b * 'a unfolder).

MLton.Vector.unfoldi does that as well.  Do you think its type should
be changed to

 val unfoldi: int * 'b * (int * 'b -> 'a * 'b) -> 'a vector * 'b