Skip to content

Instantly share code, notes, and snippets.

@sighingnow
Last active July 6, 2018 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sighingnow/298bcf267321ffe2c4e7c394e609f1c6 to your computer and use it in GitHub Desktop.
Save sighingnow/298bcf267321ffe2c4e7c394e609f1c6 to your computer and use it in GitHub Desktop.
Unsafe perform computation in some monads.
import Control.Monad.ST
import System.IO.Unsafe
import Unsafe.Coerce
unsafePerformST :: ST s a -> a
unsafePerformST m = unsafePerformIO $
stToIO $ -- unsafely do it
unsafeCoerce m -- convert to ST Realworld a
{-# NOINLINE unsafePerformST #-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment