summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_run/TypeRep.hs
blob: 002e4fbac03d431562a1cedd69b30307e31169e6 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE TypeOperators #-}

import Data.Typeable
import Data.Kind
import GHC.Exts

-- Test that Typeable works for various wired-in types.
-- See, for instance, #11120.

rep :: forall a. Typeable a => TypeRep
rep = typeRep (Proxy :: Proxy a)

main :: IO ()
main = do
  -- the basics
  print $ rep @String
  print $ rep @Char
  print $ rep @Int
  print $ rep @Word
  print $ rep @Double
  print $ rep @(IO ())
  print $ rep @IO
  print $ rep @"hi"
  print $ rep @(Char, Int, String)
  print $ rep @Bool
  print $ rep @Ordering
  print $ rep @(Int -> Int)
  print $ rep @((Eq Int, Eq String) :: Constraint)

  -- Unboxed things (#12049)
  print $ rep @Int#
  print $ rep @(##)
  print $ rep @(# Int#, Int #)

  -- Various instantiations of a kind-polymorphic type
  print $ rep @(Proxy (Eq Int))
  print $ rep @(Proxy (Int, Int))
  print $ rep @(Proxy "hello world")
  print $ rep @(Proxy 1)
  print $ rep @(Proxy [1,2,3])
  print $ rep @(Proxy 'EQ)
  print $ rep @(Proxy TYPE)
  print $ rep @(Proxy (TYPE 'LiftedRep))
  print $ rep @(Proxy *)
  print $ rep @(Proxy ★)
  print $ rep @(Proxy 'LiftedRep)

  -- Something lifted and primitive
  print $ rep @RealWorld  -- #12132