diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Data/Packed/Internal/Vector.hs | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs index 5892e67..85e7f4f 100644 --- a/lib/Data/Packed/Internal/Vector.hs +++ b/lib/Data/Packed/Internal/Vector.hs | |||
@@ -34,7 +34,7 @@ module Data.Packed.Internal.Vector ( | |||
34 | import Data.Packed.Internal.Common | 34 | import Data.Packed.Internal.Common |
35 | import Data.Packed.Internal.Signatures | 35 | import Data.Packed.Internal.Signatures |
36 | import Foreign.Marshal.Alloc(free) | 36 | import Foreign.Marshal.Alloc(free) |
37 | import Foreign.Marshal.Array(peekArray, pokeArray, copyArray, advancePtr) | 37 | import Foreign.Marshal.Array(peekArray, copyArray, advancePtr) |
38 | import Foreign.ForeignPtr(ForeignPtr, castForeignPtr) | 38 | import Foreign.ForeignPtr(ForeignPtr, castForeignPtr) |
39 | import Foreign.Ptr(Ptr) | 39 | import Foreign.Ptr(Ptr) |
40 | import Foreign.Storable(Storable, peekElemOff, pokeElemOff, sizeOf) | 40 | import Foreign.Storable(Storable, peekElemOff, pokeElemOff, sizeOf) |
@@ -57,6 +57,7 @@ import GHC.IOBase hiding (liftIO) | |||
57 | 57 | ||
58 | import qualified Data.Vector.Storable as Vector | 58 | import qualified Data.Vector.Storable as Vector |
59 | import Data.Vector.Storable(Vector, | 59 | import Data.Vector.Storable(Vector, |
60 | fromList, | ||
60 | unsafeToForeignPtr, | 61 | unsafeToForeignPtr, |
61 | unsafeFromForeignPtr, | 62 | unsafeFromForeignPtr, |
62 | unsafeWith) | 63 | unsafeWith) |
@@ -102,11 +103,6 @@ createVector n = do | |||
102 | 4 |> [2.0,3.0,5.0,7.0]@ | 103 | 4 |> [2.0,3.0,5.0,7.0]@ |
103 | 104 | ||
104 | -} | 105 | -} |
105 | fromList :: Storable a => [a] -> Vector a | ||
106 | fromList l = unsafePerformIO $ do | ||
107 | v <- createVector (length l) | ||
108 | unsafeWith v $ \ p -> pokeArray p l | ||
109 | return v | ||
110 | 106 | ||
111 | safeRead v = inlinePerformIO . unsafeWith v | 107 | safeRead v = inlinePerformIO . unsafeWith v |
112 | {-# INLINE safeRead #-} | 108 | {-# INLINE safeRead #-} |