summaryrefslogtreecommitdiff
path: root/testsuite/tests/th/TH_StringPrimL.hs
blob: 92f791fb5631913a6da3a603d59badbb022b2158 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{-# LANGUAGE MagicHash #-}
module Main where

import Language.Haskell.TH
import GHC.Prim(Addr#)
import GHC.Ptr
import Foreign.Marshal.Array (peekArray)
import Data.Word (Word8)

check_equal :: [Word8] -> Addr# -> IO ()
check_equal bytes addr = do
  bytes' <- peekArray (length bytes) (Ptr addr)
  print (bytes == bytes')

main = do
  -- check round-trip
  check_equal [0..255] $(litE $ stringPrimL [0..255])

  -- check printing
  let e = LitE (StringPrimL [0..255])
  print e
  putStrLn (pprint e)