Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds runSmallUnliftedArrayST #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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