replaceBuffer :: forall a. Storable a => BufferTarget -> [a] -> IO ()
replaceBuffer target elems = do arr <- newListArray (0, len - 1) elems
                                withStorableArray arr $ \ptr ->
                                  bufferData target $= (n, ptr, StaticDraw)
  where len = length elems
        n = fromIntegral $ len * sizeOf (undefined::a)

-- |Allocate and fill a 'BufferObject' with the given number of bytes
-- from the supplied pointer.
replaceBuffer :: forall a. Storable a => BufferTarget -> [a] -> IO ()
replaceBuffer target elems = do arr <- newListArray (0, len - 1) elems
                                withStorableArray arr $ \ptr ->
                                  bufferData target $= (n, ptr, StaticDraw)
  where len = length elems
        n = fromIntegral $ len * sizeOf (undefined::a)

-- |Allocate and fill a 'BufferObject' with the given number of bytes
-- from the supplied pointer.
replaceBuffer target elems = do arr <- newListArray (0, len - 1) elems
                                withStorableArray arr $ \ptr ->
                                  bufferData target $= (n, ptr, StaticDraw)
  where len = length elems
        n = fromIntegral $ len * sizeOf (undefined::a)

-- |Allocate and fill a 'BufferObject' with the given number of bytes
-- from the supplied pointer.