Alastair Reid writes:
 > [EMAIL PROTECTED] (S.D.Mechveliani) writes:
 > > Recent Haskell ignores the possibility of the automatic type 
 > > conversion. Thus, 
 > >                           1 + 1%2  
 > > is ill-typed.
 > 
 > and goes on to propose a fix.
 > 
 > This expression is perfectly well typed: Hugs 1.4 accepts it without
 > any problems:
 > 
 >   Prelude> 1 + 1%2
 >   3 % 2
 > 
 > Perhaps you should send a bug report to whoever wrote your compiler?

Just to offer what I hope is a clarification...

I think that Sergey is offering a proposal for numeric type coercion,
such that (for example) for n :: Int and x :: Float, n*x will be well
typed, without the need to write (fromInteger n)*x.

The reason that 1 + 1%2 is well-typed in Hugs is that numeric literals
are overloaded (the 1s and 2 here are implicitly preceded by fromInteger).

The 1.2 version of the Gentle Introduction (SIGPLAN notices 27:5, May
1992) explained this rather nicely, I thought.  (I can't find that
explanation in the 1.4 version at haskell.org.)  It is in the Report,
at http://haskell.org/onlinereport/basic.html#sect6.3.1

Eric


Reply via email to