Typo
[packages/base.git] / tests / dynamic004.hs
1 module Main where
2
3 import Data.Typeable
4 import Data.Typeable.Internal
5 import GHC.Fingerprint
6 import Text.Printf
7
8 f :: Typeable a => Int -> a -> [TypeRep]
9 f 0 a = []
10 f n a = typeOf a : f (n-1) [a]
11
12 -- pointwise compare 1000x1001 TypeReps, there should be exactly 1000 equalities
13 -- (can be used as a benchmark)
14 main = print $ length [ t1 | t1 <- f 1000 (), t2 <- f 1001 (), t1 == t2 ]
15
16 {-
17 DEBUGGING code to help find bugs in the TypeRep implementation when
18 this test fails:
19
20 where
21 g (x:xs) (y:ys)
22 | x == y = g xs ys
23 | otherwise = do
24 print x
25 case x of
26 TypeRep f1 (TyCon f2 _ _ _) [TypeRep f3 _ _] ->
27 printf "f1: %s\nf2: %s\nf3: %s\n" (show_fp f1) (show_fp f2) (show_fp f3)
28 case y of
29 TypeRep f1 (TyCon f2 _ _ _) [TypeRep f3 _ _] ->
30 printf "f1: %s\nf2: %s\nf3: %s\n" (show_fp f1) (show_fp f2) (show_fp f3)
31 g _ _ = return ()
32
33 show_fp :: Fingerprint -> String
34 show_fp (Fingerprint h l) =
35 printf "%x %x" h l
36 -}