summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-regress/lib/should_run/dynamic004.hs
blob: e6b7a82bfd40c031b0c1edbdb3699d685085a54d (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
module Main where

import Data.Typeable
import Data.Typeable.Internal
import GHC.Fingerprint
import Text.Printf

f :: Typeable a => Int -> a -> [TypeRep]
f 0 a = []
f n a = typeOf a : f (n-1) [a]

-- pointwise compare 1000x1001 TypeReps, there should be exactly 1000 equalities
-- (can be used as a benchmark)
main = print $ length [ t1 | t1 <- f 1000 (), t2 <- f 1001 (), t1 == t2 ]

{-
 DEBUGGING code to help find bugs in the TypeRep implementation when
 this test fails:

 where
   g (x:xs) (y:ys)
     | x == y = g xs ys
     | otherwise = do
         print x
         case x of
           TypeRep f1 (TyCon f2 _ _ _) [TypeRep f3 _ _] ->
              printf "f1: %s\nf2: %s\nf3: %s\n" (show_fp f1) (show_fp f2) (show_fp f3)
         case y of
           TypeRep f1 (TyCon f2 _ _ _) [TypeRep f3 _ _] ->
              printf "f1: %s\nf2: %s\nf3: %s\n" (show_fp f1) (show_fp f2) (show_fp f3)
   g _ _ = return ()

   show_fp :: Fingerprint -> String
   show_fp (Fingerprint h l) =
       printf "%x %x" h l
-}