[project @ 1998-04-17 15:58:37 by simonm]
[ghc-hetmet.git] / ghc / tests / typecheck / should_compile / tc096.hs
1 module ShouldSucceed where
2
3 --!!! monomorphism restriction and defaulting
4
5 x = 3
6
7 main = print $ 6 / x
8
9 {-
10 Hugs 1.4 complains: ERROR "Strange.hs" (line 3): Int is not an
11 instance of class "Fractional".  GHC however compiles the program.
12 Substitute for x and Hugs is happy.  What's going on?
13
14 I haven't studied the numeric classes much so perhaps I'm missing
15 something obvious here.  (I see that the bugs page alludes to some 1.4
16 features not in Hugs leading to type errors.  If this is it, maybe you
17 should give it as an example?)
18
19   Bjarte
20
21 ------- Message 2
22
23 Date:    Wed, 25 Feb 98 14:01:35 -0500
24 From:    "John C. Peterson" <peterson-john@CS.YALE.EDU>
25 To:      bjartem@idi.ntnu.no
26 cc:      hugs-bugs@CS.YALE.EDU
27 Subject: Re: Fractional and Int?
28
29 This is a known hugs bug.  x should be monomorphic, allowing the usage
30 in main to constrain it to Fractional.  Instead, it is generalized and
31 then defaulted to Int without being influenced by main.  So ghc is
32 right and hugs is wrong on this one.  I expect this will be fixed
33 eventually. 
34
35    John
36 -}