summaryrefslogtreecommitdiff
path: root/testsuite/tests/codeGen/should_compile/T18397.hs
blob: 6941b811ba57b1d6e0c4e66a1bdcd741056b33f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE UnboxedTuples #-}
module T18397 where

import GHC.Exts
import GHC.ST

data MutableArray s a = MutableArray (MutableArray# s a)

runArray#
  :: (forall s. ST s (MutableArray s a))
  -> Array# a
runArray# m = case runRW# $ \s ->
  case unST m s of { (# s', MutableArray mary# #) ->
  unsafeFreezeArray# mary# s'} of (# _, ary# #) -> ary#

unST :: ST s a -> State# s -> (# State# s, a #)
unST (ST f) = f