[Haskell-cafe] ANN: vector-buffer package 0.1

Luke Palmer lrpalmer at gmail.com
Tue Feb 15 05:08:17 CET 2011


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
<haskell.vivian.mcphail at gmail.com> 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
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>



More information about the Haskell-Cafe mailing list