summaryrefslogtreecommitdiff
path: root/testsuite/tests/th/T16976.hs
blob: 4d2c889794697ba18eafdb57b90d16e8a77a5b45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE NoMonomorphismRestriction #-}

module T16976 where

import Language.Haskell.TH (reifyType, runIO)
import Language.Haskell.TH.Ppr (ppr_sig)
import Data.Foldable (for_)
import System.IO (hPrint, stderr)

data T s = MkT1 | MkT2

aNumber = 5
aString = "hi"

pattern P = MkT1

do  let names = [ 'aNumber, 'aString    -- local value declarations
                , 'MkT1, 'MkT2          -- local data constructor declarations
                , ''T                   -- local type constructor declarations
                , 'P                    -- local pattern synonyms
                , 'not, 'id             -- library value declarations
                , 'Nothing              -- library data constructor declarations
                , ''Maybe, ''Functor    -- library type constructor declarations
                ]
    for_ names $ \name -> do
      t <- reifyType name
      -- Why 'hPrint stderr' instead of 'print'? This is a workaround for the
      -- testsuite driver quirk, otherwise the test fails in 'ext-interp' way.
      runIO . hPrint stderr $ ppr_sig name t
    return []