<BR>It is strange because fromInt works in the hugs prompt But when I use it
in my haskell script it doesn´t work.<BR><BR>Prelude&gt;fromInt 5 :: Float
(ok!)<BR><BR>but&nbsp;<BR><BR><FONT face="Courier New">average :: Int -&gt;
Float<BR>average n = fromInt ( sum n ) :: Float / fromInt n ::
Float</FONT><BR><BR>doesn´t work...<BR><BR>fromInteger works in hugs prompt
and inside the haskell script too.<BR><BR>Stenio.<BR><BR>
<BLOCKQUOTE dir=ltr style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px;
MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">--------- Mensagem Original --------<BR>De:
"Iavor S. Diatchki" &lt;diatchki@cse.ogi.edu&gt;<BR>Para:
"Markus.Schnell@infineon.com" &lt;Markus.Schnell@infineon.com&gt;<BR>Cópia:
haskell@haskell.org, stenio@uesb.br<BR>Assunto: Re: AW: [Haskell] Hugs
Nov2003 X Nov2002<BR>Data: 16/03/04 16:52<BR><BR><FONT face="Courier New"
size=2><BR>hi,<BR>i believe you should use<BR>fromIntegral :: (Integral a,
Num b) =&gt; a -&gt; b<BR><BR>Since Int is in the Integral class, and Float
is in the Num class<BR>this should do exactly the job you need.<BR><BR>For
the other functions that were not working --- they were moved to<BR>the Char
module, so you need to add "import Char" at the top of
your<BR>program.<BR><BR><BR><BR><A class=autolink
href="mailto:Markus.Schnell@infineon.com">Markus.Schnell@infineon.com</A>
wrote:<BR><BR>&gt; try<BR>&gt;<BR>&gt; fromInt = fromInteger .
toInteger<BR><BR>this does not seem like a good idea, as you start with an
Int,<BR>then convert it to an Integer, and then you make a Float out of
that.<BR>seems like a waste.<BR><BR>hope this
helps<BR>-iavor<BR><BR><BR>&gt;<BR>&gt; Markus<BR>&gt;<BR>&gt;<BR>&gt;
--<BR>&gt; Markus Schnell<BR>&gt;<BR>&gt; -----Ursprüngliche
Nachricht-----<BR>&gt; *Von:* <A class=autolink
href="mailto:haskell-bounces@haskell.org">haskell-bounces@haskell.org</A><BR>&gt;
[mailto:haskell-bounces@haskell.org] *Im Auftrag von *Stenio<BR>&gt;
*Gesendet:* Dienstag, 16. März 2004 10:29<BR>&gt; *An:* Ketil Malde<BR>&gt;
*Cc:* <A class=autolink
href="mailto:haskell@haskell.org">haskell@haskell.org</A><BR>&gt; *Betreff:*
Re: [Haskell] Hugs Nov2003 X Nov2002<BR>&gt;<BR>&gt; fromInteger works, but
it converts from Integer to Float. In my<BR>&gt; script, I need fromInt
because it converts from Int to Float.<BR>&gt;<BR>&gt;
Example:<BR>&gt;<BR>&gt; average :: Int -&gt; Float<BR>&gt; average n =
fromInt ( sum n ) :: Float / fromInt n :: Float<BR>&gt;<BR>&gt; It works
only in Hugs November 2002<BR>&gt;<BR>&gt; Stenio.<BR>&gt;<BR>&gt; ---------
Mensagem Original --------<BR>&gt; De: "Ketil Malde"
&lt;ketil+haskell@ii.uib.no&gt;<BR>&gt; Para: "Stenio"
&lt;stenio@uesb.br&gt;<BR>&gt; Cópia: <A class=autolink
href="mailto:haskell@haskell.org">haskell@haskell.org</A><BR>&gt; Assunto:
Re: [Haskell] Hugs Nov2003 X Nov2002<BR>&gt; Data: 16/03/04
12:07<BR>&gt;<BR>&gt;<BR>&gt; "Stenio" &lt;stenio@uesb.br&gt;
writes:<BR>&gt;<BR>&gt; &gt; I was using Hugs November 2002 and the function
fromInt<BR>&gt; works fine,<BR>&gt; &gt; but in the version November 2003
the same function doesn´t work.<BR>&gt;<BR>&gt; I'm too lazy to check the
standard, so I'll just assume Hugs was<BR>&gt; wrong. I think the solution
is to use "fromIntegral" instead. GHCi<BR>&gt; also has "fromInteger",
although I'm not quite sure why we<BR>&gt; need this<BR>&gt; in addition to
"fromIntegral"? (Possibly because it is a member of<BR>&gt; Num, and it
would break too much code to remove it)<BR>&gt;<BR>&gt; -kzm<BR>&gt;
--<BR>&gt; If I haven't seen further, it is by standing in the
footprints<BR>&gt; of
giants<BR>&gt;<BR>&gt;<BR>&gt;<BR>&gt;------------------------------------------------------------------------<BR>&gt;<BR>&gt;_______________________________________________<BR>&gt;Haskell
mailing
list<BR>&gt;Haskell@haskell.org<BR>&gt;http://www.haskell.org/mailman/listinfo/haskell<BR>&gt;<BR>&gt;<BR><BR>_______________________________________________<BR>Haskell
mailing list<BR><A class=autolink
href="mailto:Haskell@haskell.org">Haskell@haskell.org</A><BR><A
class=autolink href="http://www.haskell.org/mailman/listinfo/haskell"
target=_blank>http://www.haskell.org/mailman/listinfo/haskell</A><BR><BR><BR><BR><BR><BR><BR></FONT></DIV></BLOCKQUOTE>