From 29c622322ee14b10b2a73b40fb403bb7eaa2ec40 Mon Sep 17 00:00:00 2001 From: Mike Ledger Date: Mon, 24 Jun 2013 21:51:44 +1000 Subject: explicit exports, fix argument order of appMatrixRaw --- lib/Data/Packed/Foreign.hs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'lib/Data') diff --git a/lib/Data/Packed/Foreign.hs b/lib/Data/Packed/Foreign.hs index a94a979..efa51ca 100644 --- a/lib/Data/Packed/Foreign.hs +++ b/lib/Data/Packed/Foreign.hs @@ -6,7 +6,12 @@ -- @ glUniformMatrix4fv 0 1 (fromIntegral gl_TRUE) \`appMatrix\` perspective 0.01 100 (pi\/2) (4\/3) -- @ -- -module Data.Packed.Foreign where +module Data.Packed.Foreign + ( app + , appVector, appVectorLen + , appMatrix, appMatrixLen, appMatrixRaw, appMatrixRawLen + , unsafeMatrixToVector, unsafeMatrixToForeignPtr + ) where import Data.Packed.Internal import qualified Data.Vector.Storable as S import Foreign (Ptr, ForeignPtr, Storable) @@ -14,6 +19,8 @@ import Foreign.C.Types (CInt) import GHC.Base (IO(..), realWorld#) {-# INLINE unsafeInlinePerformIO #-} +-- | If we use unsafePerformIO, it may not get inlined, so in a function that returns IO (which are all safe uses of app* in this module), there would be +-- unecessary calls to unsafePerformIO or its internals. unsafeInlinePerformIO :: IO a -> a unsafeInlinePerformIO (IO f) = case f realWorld# of (# _, x #) -> x @@ -65,8 +72,8 @@ appMatrixLen f x = unsafeInlinePerformIO (S.unsafeWith (flatten x) (return . f r c = fromIntegral (cols x) {-# INLINE appMatrixRaw #-} -appMatrixRaw :: Storable a => Matrix a -> (Ptr a -> b) -> b -appMatrixRaw x f = unsafeInlinePerformIO (S.unsafeWith (xdat x) (return . f)) +appMatrixRaw :: Storable a => (Ptr a -> b) -> Matrix a -> b +appMatrixRaw f x = unsafeInlinePerformIO (S.unsafeWith (xdat x) (return . f)) {-# INLINE appMatrixRawLen #-} appMatrixRawLen :: Element a => (CInt -> CInt -> Ptr a -> b) -> Matrix a -> b -- cgit v1.2.3