[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / interpreter / test / typechecker / t000.hs
1 --!!! Testing typechecker (fixed in Hugs 1.01)
2
3 {-
4 Hi again,
5
6 While I am at bug reporting I should as well inform you of another
7 problem that I encountered.
8
9 While testing different variations of the gc-bug test program I
10 found a difference between what would compile in the original hugs.1.01
11 and the hacked.hugs that I downloaded from the ftp directory.
12
13 In the hacked.hugs I have only changed: SUNOS 0, LINUX 1, and finally
14 I had to remove the external definition of strchr because it conflicted
15 with some include file definition. (Of course this will turn out
16 to be the reason, right?)
17
18 I also had to add the Ordering type in hugs.prelude that came with
19 hacked.hugs.tar.gz, because it was required to be loaded.
20
21 Have fun,
22
23 Sverker
24
25 PS:
26
27 The error message was:
28
29 ERROR "/home/nilsson/ngof/simpleprims/src/tbugx.gs" (line 15): Insufficient class constraints in instance member binding
30 *** Context  : (T a, T b, T c)
31 *** Required : T d
32
33 The test program, tbugx.gs, is:
34
35 -}
36 module TestTypes where
37
38 class T a where
39         t :: Int ->  a
40
41 instance T Int where
42         t = id
43
44 instance (T a, T b) => T (a, b) where
45         t p = 
46             (t p, t p)
47
48
49 instance (T a, T b, T c) => T (a, b, c) where
50 -- The following compiles in hugs1.01, but not in hacked.hugs!
51 -- It induces the GC bug as well.
52         t p =  (a, b, c) where
53                         tp = t p
54                         a = fst tp
55                         bc = snd tp
56                         b = fst bc
57                         c = snd bc
58 -- The following does not induce the GC bug.
59 -- But as the previous one, it compiles only in hugs1.01, not in hacked.hugs.
60 --      t p =  (a, b, c) where
61 --                      a = t p
62 --                      bc = t p
63 --                      b = fst bc
64 --                      c = snd bc
65
66 t2:: Int -> (Int,Int)
67 t2 = t                  -- t2 has no problems
68
69 t3:: Int -> (Int,Int,Int)
70 t3 = t                  -- t3 has problems