diff options
Diffstat (limited to 'testsuite/tests/th/TH_StaticPointers02.hs')
-rw-r--r-- | testsuite/tests/th/TH_StaticPointers02.hs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/testsuite/tests/th/TH_StaticPointers02.hs b/testsuite/tests/th/TH_StaticPointers02.hs new file mode 100644 index 0000000000..1f619a7569 --- /dev/null +++ b/testsuite/tests/th/TH_StaticPointers02.hs @@ -0,0 +1,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) + |] + ) |