Hi Luke,
Apologies, I think I got bitten by unsafePerformIO.
The reason it wasn't in the IO monad is that the Vector created from the
Buffer is supposed to be immutable.
I've changed the API so that:
main = do
buf <- newBuffer 10 :: IO (Buffer Int)
pushNextElement buf 1
v1 <- toVector
This interface is an outlaw.
main = do
buf <- newBuffer 10 :: IO (Buffer Int)
pushNextElement buf 1
let v1 = V.toList (toVector buf)
v2 = V.toList (toVector buf)
print v1
pushNextElement buf 2
print v2
Despite v1 and v2 being defined to equal the exact same thing,
Hi,
I have uploaded a small package, vector-buffer, to hackage. It provides a
buffer that can be turned into a Data.Vector.Storable. The mapM* functions
map from the oldest element, not the first. Similarly for the derived
Vector.
Feature requests etc. welcome.
Vivian