[commit: packages/primitive] ghc-head: Add INLINE pragmas (1242ac3)
git at git.haskell.org
git at git.haskell.org
Thu Sep 26 11:44:14 CEST 2013
Repository : ssh://git@git.haskell.org/primitive
On branch : ghc-head
Link : http://git.haskell.org/packages/primitive.git/commitdiff/1242ac34ef7a4f47d256749562bc477d64a39712
>---------------------------------------------------------------
commit 1242ac34ef7a4f47d256749562bc477d64a39712
Author: Roman Leshchinskiy <rl at cse.unsw.edu.au>
Date: Thu Jan 26 14:35:57 2012 -0700
Add INLINE pragmas
>---------------------------------------------------------------
1242ac34ef7a4f47d256749562bc477d64a39712
Control/Monad/Primitive.hs | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/Control/Monad/Primitive.hs b/Control/Monad/Primitive.hs
index b16142c..37b22fd 100644
--- a/Control/Monad/Primitive.hs
+++ b/Control/Monad/Primitive.hs
@@ -50,37 +50,47 @@ instance PrimMonad IO where
type PrimState IO = RealWorld
primitive = IO
internal (IO p) = p
+ {-# INLINE primitive #-}
+ {-# INLINE internal #-}
instance PrimMonad (ST s) where
type PrimState (ST s) = s
primitive = ST
internal (ST p) = p
+ {-# INLINE primitive #-}
+ {-# INLINE internal #-}
-- | Convert a 'PrimMonad' to another monad with the same state token.
primToPrim :: (PrimMonad m1, PrimMonad m2, PrimState m1 ~ PrimState m2)
=> m1 a -> m2 a
+{-# INLINE primToPrim #-}
primToPrim m = primitive (internal m)
-- | Convert a 'PrimMonad' with a 'RealWorld' state token to 'IO'
primToIO :: (PrimMonad m, PrimState m ~ RealWorld) => m a -> IO a
+{-# INLINE primToIO #-}
primToIO = primToPrim
-- | Convert a 'PrimMonad' to 'ST'
primToST :: PrimMonad m => m a -> ST (PrimState m) a
+{-# INLINE primToST #-}
primToST = primToPrim
-- | Convert a 'PrimMonad' to another monad with a possibly different state
-- token. This operation is highly unsafe!
unsafePrimToPrim :: (PrimMonad m1, PrimMonad m2) => m1 a -> m2 a
+{-# INLINE unsafePrimToPrim #-}
unsafePrimToPrim m = primitive (unsafeCoerce# (internal m))
-- | Convert any 'PrimMonad' to 'ST' with an arbitrary state token. This
-- operation is highly unsafe!
unsafePrimToST :: PrimMonad m => m a -> ST s a
+{-# INLINE unsafePrimToST #-}
unsafePrimToST = unsafePrimToPrim
-- | Convert any 'PrimMonad' to 'IO'. This operation is highly unsafe!
unsafePrimToIO :: PrimMonad m => m a -> IO a
+{-# INLINE unsafePrimToIO #-}
unsafePrimToIO = unsafePrimToPrim
unsafeInlinePrim :: PrimMonad m => m a -> a
@@ -96,6 +106,7 @@ unsafeInlineST :: ST s a -> a
unsafeInlineST = unsafeInlinePrim
touch :: PrimMonad m => a -> m ()
+{-# INLINE touch #-}
touch x = unsafePrimToPrim
$ (primitive (\s -> case touch# x s of { s' -> (# s', () #) }) :: IO ())
More information about the ghc-commits
mailing list