Last active
May 12, 2025 18:08
-
-
Save TerrorJack/5acc93660ba8669ad4f1f2f7989d9d03 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE MagicHash #-} | |
{-# LANGUAGE UnboxedTuples #-} | |
module Spark where | |
import GHC.Exts | |
import GHC.ST | |
spark :: a -> ST s a | |
spark x' = ST $ \s0 -> case spark# x s0 of | |
(# s1, r #) -> (# s1, r #) | |
where | |
x = runRW# $ \s0 -> case noDuplicate# s0 of | |
_ -> lazy x' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment