David Feuer
2018-03-11 06:29:25 UTC
The vector package offers
createT :: Traversable t
=> (forall s. ST s (t (MVector s a)))
-> t (Vector a)
This is a generalization of create, which is very similar to runSTArray in
the array package. I suggest we add functions
runSTArrays :: Traversable t
=> (forall s. ST s (t (STArray s i e)))
-> t (Array i e)
runSTUArrays :: Traversable t
=> (forall s. ST s (t (STUArray s i e)))
-> t (UArray i e)
Why do I think it's worth the trouble? While it's occasionally useful to
create multiple arrays of the same type in one go, I think the Maybe and
(a,) Traversable instances, and their compositions, are likely more
important. I can use (a,) to record some extra information while building
an array. I can use Maybe to give up and not produce an array. And the
compositions let me do both in different ways.
createT :: Traversable t
=> (forall s. ST s (t (MVector s a)))
-> t (Vector a)
This is a generalization of create, which is very similar to runSTArray in
the array package. I suggest we add functions
runSTArrays :: Traversable t
=> (forall s. ST s (t (STArray s i e)))
-> t (Array i e)
runSTUArrays :: Traversable t
=> (forall s. ST s (t (STUArray s i e)))
-> t (UArray i e)
Why do I think it's worth the trouble? While it's occasionally useful to
create multiple arrays of the same type in one go, I think the Maybe and
(a,) Traversable instances, and their compositions, are likely more
important. I can use (a,) to record some extra information while building
an array. I can use Maybe to give up and not produce an array. And the
compositions let me do both in different ways.