
In response to a bit of an obscure use case I had, I created this very simple library which gives you a Monad with a single operation, `push :: a -> m ()`. This operation pushes an item onto a stack (represented under the hood by a mutable ST vector). When you run the monad, you get the stack out as a vector. The library is quite fast. It's about 2x faster than C++'s std::vec::push_back compiled without optimizations, and about 40% as fast as std::vec::push_back when compiled with G++ -O2. There's almost certainly some low-hanging optimization fruit for anyone skilled at Haskell optimizing. The library is parametric over choice of mutable vector. You can use Unboxed, Storable, or normal vectors. I've even included a Push Monad Transformer based on Control.Monad.ST.Trans, but that's almost certainly unsafe, per the caveats listed in the Control.Monad.ST.Trans docs. https://hackage.haskell.org/package/FastPush-0.1.0.0 https://github.com/wyager/FastPush/ Cheers, Will

Thanks Will, This looks like a useful package! Would you mind extending the lower bound on vector a bit, in order to simplify installation with stack? Stackage lts and nightly still include vector-0.11. Cheers, Simon

Alright, give that a shot. I also removed some unnecessary dependencies.
The only dependencies now are base, vector, and STMonadTrans.
Cheers,
Will
On Tue, Jan 24, 2017 at 12:26 AM, Simon Jakobi
Thanks Will,
This looks like a useful package! Would you mind extending the lower bound on vector a bit, in order to simplify installation with stack? Stackage lts and nightly still include vector-0.11.
Cheers, Simon

Thanks, works great!
2017-01-24 8:00 GMT+01:00 William Yager
Alright, give that a shot. I also removed some unnecessary dependencies. The only dependencies now are base, vector, and STMonadTrans.
Cheers, Will
On Tue, Jan 24, 2017 at 12:26 AM, Simon Jakobi
wrote: Thanks Will,
This looks like a useful package! Would you mind extending the lower bound on vector a bit, in order to simplify installation with stack? Stackage lts and nightly still include vector-0.11.
Cheers, Simon
participants (2)
-
Simon Jakobi
-
William Yager