{- |
Module : Data.StorableVector.ST.Strict
License : BSD-style
Maintainer : haskell@henning-thielemann.de
Stability : experimental
Portability : portable, requires ffi
Tested with : GHC 6.4.1
-}moduleData.StorableVector.ST.PrivatewhereimportqualifiedData.StorableVector.BaseasVimportData.StorableVector.Memory(mallocForeignPtrArray,)importControl.Monad.ST.Strict(ST,unsafeIOToST,)-- stToIO,importForeign.Ptr(Ptr,)importForeign.ForeignPtr(ForeignPtr,withForeignPtr,)importForeign.Storable(Storable,)-- import Prelude (Int, ($), (+), return, const, )importPreludehiding(read,length,)dataVectorsa=SV{-# UNPACK #-}!(ForeignPtra){-# UNPACK #-}!Int-- length-- | Wrapper of mallocForeignPtrArray.create::(Storablea)=>Int->(Ptra->IO())->IO(Vectorsa)createlf=dofp<-mallocForeignPtrArraylwithForeignPtrfpfreturn$!SVfpl{-# INLINE unsafeCreate #-}unsafeCreate::(Storablea)=>Int->(Ptra->IO())->STs(Vectorsa)unsafeCreatelf=unsafeIOToST$createlf{-
This function must be in ST monad,
since it is usually called
as termination of a series of write accesses to the vector.
We must assert that no read access to the V.Vector can happen
before the end of the write accesses.
(And the caller must assert, that he actually never writes again into that vector.)
-}{-# INLINE unsafeToVector #-}unsafeToVector::Vectorsa->STs(V.Vectora)unsafeToVector(SVxl)=return(V.SVx0l)