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, this
program prints two distinct lines.
toVector depends on the current state of the buffer. If this is to be
a law-abiding interface, toVector must return a value in IO:
toVector :: (Storable a) => Buffer a -> IO (Vector a)
Luke
On Mon, Feb 14, 2011 at 7:28 PM, Alexander McPhail
<[email protected]> wrote:
> 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
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe