diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | lib/Data/Packed/Internal/Vector.hs | 8 |
2 files changed, 4 insertions, 6 deletions
@@ -17,3 +17,5 @@ index.html | |||
17 | title.md | 17 | title.md |
18 | 18 | ||
19 | /base-reinstall.sh | 19 | /base-reinstall.sh |
20 | .cabal-sandbox | ||
21 | cabal.sandbox.config | ||
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 #-} |