summaryrefslogtreecommitdiff
path: root/testsuite/tests/codeGen/should_run/T12622.hs
blob: 81e5b04fa3bcd3ccdc310f2c859f76d6e736d082 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- Test that static pointers still work when the users try
-- to unpack StaticPtr fields.
{-# LANGUAGE StaticPointers #-}
{-# LANGUAGE LambdaCase #-}

import GHC.StaticPtr
import T12622_A

g = True

main :: IO ()
main = do
  let T s = sg :: T (Bool -> Bool)
  lookupKey s >>= \f -> print (f True)

lookupKey :: StaticPtr a -> IO a
lookupKey p = unsafeLookupStaticPtr (staticKey p) >>= \case
  Just p -> return $ deRefStaticPtr p
  Nothing -> error $ "couldn't find " ++ show (staticPtrInfo p)