| storablevector-0.2.1: Fast, packed, strict storable arrays with a list interface like ByteString | Source code | Contents | Index |
|
Data.StorableVector.ST.Lazy | Portability | portable, requires ffi | Stability | experimental | Maintainer | haskell@henning-thielemann.de |
|
|
|
Description |
Tested with : GHC 6.4.1
Interface for access to a mutable StorableVector.
|
|
Synopsis |
|
|
|
Documentation |
|
|
|
|
|
|
|
|
Control.Monad.ST.runST (do arr <- new_ 10; Monad.zipWithM_ (write arr) [9,8..0] ['a'..]; read arr 3)
|
|
|
VS.unpack $ runSTVector (do arr <- new_ 10; Monad.zipWithM_ (write arr) [9,8..0] ['a'..]; return arr)
|
|
|
|
|
|
|
|
|
|
|
|
|
:module + Data.STRef
VS.unpack $ Control.Monad.ST.runST (do ref <- newSTRef 'a'; mapST (\ _n -> do c <- readSTRef ref; modifySTRef ref succ; return c) (VS.pack [1,2,3,4::Data.Int.Int16]))
|
|
|
*Data.StorableVector.ST.Strict Data.STRef> VL.unpack $ Control.Monad.ST.runST (do ref <- newSTRef 'a'; mapSTLazy (\ _n -> do c <- readSTRef ref; modifySTRef ref succ; return c) (VL.pack VL.defaultChunkSize [1,2,3,4::Data.Int.Int16]))
"abcd"
The following should not work on infinite streams,
since we are in ST with strict >>=.
But it works. Why?
*Data.StorableVector.ST.Strict Data.STRef.Lazy> VL.unpack $ Control.Monad.ST.Lazy.runST (do ref <- newSTRef 'a'; mapSTLazy (\ _n -> do c <- readSTRef ref; modifySTRef ref succ; return c) (VL.pack VL.defaultChunkSize [0::Data.Int.Int16 ..]))
"Interrupted.
|
|
Produced by Haddock version 2.4.2 |