From dbd943b89ff481e0971f86c2271223cfddee7a02 Mon Sep 17 00:00:00 2001 From: Vivian McPhail Date: Sun, 26 Sep 2010 21:03:59 +0000 Subject: add note about strictness --- lib/Data/Packed/Internal/Vector.hs | 2 ++ lib/Data/Packed/Vector.hs | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/Data') diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs index 7360f93..ba68909 100644 --- a/lib/Data/Packed/Internal/Vector.hs +++ b/lib/Data/Packed/Internal/Vector.hs @@ -387,6 +387,7 @@ foldVectorG f s0 v = foldLoop g s0 (dim v) ------------------------------------------------------------------- -- | monadic map over Vectors +-- the monad @m@ must be strict mapVectorM :: (Storable a, Storable b, Monad m) => (a -> m b) -> Vector a -> m (Vector b) mapVectorM f v = do w <- return $! unsafePerformIO $! createVector (dim v) @@ -419,6 +420,7 @@ mapVectorM_ f v = do {-# INLINE mapVectorM_ #-} -- | monadic map over Vectors with the zero-indexed index passed to the mapping function +-- the monad @m@ must be strict mapVectorWithIndexM :: (Storable a, Storable b, Monad m) => (Int -> a -> m b) -> Vector a -> m (Vector b) mapVectorWithIndexM f v = do w <- return $! unsafePerformIO $! createVector (dim v) diff --git a/lib/Data/Packed/Vector.hs b/lib/Data/Packed/Vector.hs index 23fe37f..e79e237 100644 --- a/lib/Data/Packed/Vector.hs +++ b/lib/Data/Packed/Vector.hs @@ -99,7 +99,8 @@ state_put :: s -> State s () state_put s = State $ \_ -> ((),s) evalState :: State s a -> s -> a -evalState m s = fst $ runState m s +evalState m s = let (a,s') = runState m s + in seq s' a newtype MaybeT m a = MaybeT { runMaybeT :: m (Maybe a) } -- cgit v1.2.3