Skip to content

Commit

Permalink
Adds runSmallUnliftedArrayST
Browse files Browse the repository at this point in the history
  • Loading branch information
Qqwy committed Oct 5, 2024
1 parent 87a6346 commit 95723ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
packages: .


source-repository-package
type: git
location: [email protected]:Qqwy/haskell-primitive-unlifted.git
tag: 784fc78815a695db6db69c729a364663e4f0afe2
6 changes: 6 additions & 0 deletions src/Control/Monad/ST/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module Control.Monad.ST.Run
, runSmallArrayST
, runByteArrayST
, runPrimArrayST
, runSmallUnliftedArrayST
, runUnliftedArrayST

-- * Integral Types
Expand Down Expand Up @@ -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))
Expand All @@ -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))
Expand Down

0 comments on commit 95723ed

Please sign in to comment.