diff --git a/cabal.project b/cabal.project new file mode 100644 index 0000000..9ebd695 --- /dev/null +++ b/cabal.project @@ -0,0 +1,7 @@ +packages: . + + +source-repository-package + type: git + location: git@github.com:Qqwy/haskell-primitive-unlifted.git + tag: 784fc78815a695db6db69c729a364663e4f0afe2 diff --git a/src/Control/Monad/ST/Run.hs b/src/Control/Monad/ST/Run.hs index ca66dd2..ecbeb7b 100644 --- a/src/Control/Monad/ST/Run.hs +++ b/src/Control/Monad/ST/Run.hs @@ -10,6 +10,7 @@ module Control.Monad.ST.Run , runSmallArrayST , runByteArrayST , runPrimArrayST + , runSmallUnliftedArrayST , runUnliftedArrayST -- * Integral Types @@ -47,6 +48,7 @@ import Data.Primitive.ByteArray (ByteArray (ByteArray)) import Data.Primitive.PrimArray (PrimArray (PrimArray)) import Data.Primitive.SmallArray (SmallArray (SmallArray)) import Data.Primitive.Unlifted.Array (UnliftedArray_ (UnliftedArray)) +import Data.Primitive.Unlifted.SmallArray (SmallUnliftedArray_ (SmallUnliftedArray)) import GHC.Exts (Char (C#), Double (D#), Float (F#), Int (I#), Word (W#), runRW#) import GHC.Int (Int16 (I16#), Int32 (I32#), Int8 (I8#)) import GHC.ST (ST (ST)) @@ -72,6 +74,10 @@ runUnliftedArrayST :: (forall s. ST s (UnliftedArray_ unlifted_a a)) -> Unlifted {-# INLINE runUnliftedArrayST #-} runUnliftedArrayST f = UnliftedArray (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, UnliftedArray r #) -> r)) +runSmallUnliftedArrayST :: (forall s. ST s (SmallUnliftedArray_ unlifted_a a)) -> SmallUnliftedArray_ unlifted_a a +{-# INLINE runSmallUnliftedArrayST #-} +runSmallUnliftedArrayST f = SmallUnliftedArray (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, SmallUnliftedArray r #) -> r)) + runCharST :: (forall s. ST s Char) -> Char {-# INLINE runCharST #-} runCharST f = C# (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, C# r #) -> r))