[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / compiler / tests / typecheck / should_fail / tcfail065.hs
1 {-
2
3 ------- Forwarded Message
4
5 Date:    Wed, 30 Nov 1994 16:34:18 +0100
6 From:    John Hughes <rjmh@cs.chalmers.se>
7 To:      augustss@cs.chalmers.se, simonpj@dcs.gla.ac.uk
8 Subject: Nice little program
9
10
11 Lennart, Simon,
12
13 You might like to look at the fun little program below.
14
15 THUMBS DOWN to hbc for compiling it (it prints [72, 101, 108, 108, 111])
16 THUMBS UP to ghc for rejecting it --- but what an error message!
17 nhc and gofer both reject it with the right error message.
18 I haven't tried Yale Haskell.
19
20 Enjoy!
21 - ----------------------------
22 -}
23
24 class HasX a where
25   setX :: x->a->a
26
27 data X x = X x
28 instance HasX (X x) where
29   setX x (X _) = X x
30
31 changetype x = case setX x (X (error "change type!")) of X y->y
32
33 main = print (changetype "Hello" :: [Int])
34
35 {-
36 ------- End of Forwarded Message
37 -}