Skip to content

Instantly share code, notes, and snippets.

@solomon-b
Created September 18, 2024 22:37
Show Gist options
  • Save solomon-b/b995b12c5ab761f0114343c46f1f9d89 to your computer and use it in GitHub Desktop.
Save solomon-b/b995b12c5ab761f0114343c46f1f9d89 to your computer and use it in GitHub Desktop.
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
-- |
module RealWorld where
--------------------------------------------------------------------------------
import GHC.Prim
import GHC.Types
import GHC.ST
import GHC.Magic
--------------------------------------------------------------------------------
unIO :: IO a -> State# RealWorld -> (# State# RealWorld, a #)
unIO (IO a) = a
print' :: Show x => x -> State# RealWorld -> (# State# RealWorld, () #)
print' = unIO . print
-- runAction :: (State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, a #)
runAction :: (State# RealWorld -> o) -> o
runAction f = runRW# f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment