summaryrefslogtreecommitdiff
path: root/testsuite/tests/th/TH_StaticPointers02.hs
blob: 1f619a75696455ff19a3d6aa18a941dc36258d2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StaticPointers #-}

-- | A test to try the static form in splices.
--
-- A static form is defined in a splice and then it is used in the program.
--
module Main(main) where

import GHC.Fingerprint
import GHC.StaticPtr

main = print $ $(case staticKey (static 'a') of
  Fingerprint w0 w1 ->
    let w0i = fromIntegral w0 :: Integer
        w1i = fromIntegral w1 :: Integer
    in
     [| fmap (\p -> deRefStaticPtr p :: Char) $ unsafeLookupStaticPtr $
          Fingerprint (fromIntegral w0i) (fromIntegral w1i)
      |]
     )