<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>fromInt 5 :: Float
(ok!)<BR><BR>but <BR><BR><FONT face="Courier New">average :: Int ->
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" <diatchki@cse.ogi.edu><BR>Para:
"Markus.Schnell@infineon.com" <Markus.Schnell@infineon.com><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) => a -> 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>> try<BR>><BR>> 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>><BR>> Markus<BR>><BR>><BR>>
--<BR>> Markus Schnell<BR>><BR>> -----Ursprüngliche
Nachricht-----<BR>> *Von:* <A class=autolink
href="mailto:haskell-bounces@haskell.org">haskell-bounces@haskell.org</A><BR>>
[mailto:haskell-bounces@haskell.org] *Im Auftrag von *Stenio<BR>>
*Gesendet:* Dienstag, 16. März 2004 10:29<BR>> *An:* Ketil Malde<BR>>
*Cc:* <A class=autolink
href="mailto:haskell@haskell.org">haskell@haskell.org</A><BR>> *Betreff:*
Re: [Haskell] Hugs Nov2003 X Nov2002<BR>><BR>> fromInteger works, but
it converts from Integer to Float. In my<BR>> script, I need fromInt
because it converts from Int to Float.<BR>><BR>>
Example:<BR>><BR>> average :: Int -> Float<BR>> average n =
fromInt ( sum n ) :: Float / fromInt n :: Float<BR>><BR>> It works
only in Hugs November 2002<BR>><BR>> Stenio.<BR>><BR>> ---------
Mensagem Original --------<BR>> De: "Ketil Malde"
<ketil+haskell@ii.uib.no><BR>> Para: "Stenio"
<stenio@uesb.br><BR>> Cópia: <A class=autolink
href="mailto:haskell@haskell.org">haskell@haskell.org</A><BR>> Assunto:
Re: [Haskell] Hugs Nov2003 X Nov2002<BR>> Data: 16/03/04
12:07<BR>><BR>><BR>> "Stenio" <stenio@uesb.br>
writes:<BR>><BR>> > I was using Hugs November 2002 and the function
fromInt<BR>> works fine,<BR>> > but in the version November 2003
the same function doesn´t work.<BR>><BR>> I'm too lazy to check the
standard, so I'll just assume Hugs was<BR>> wrong. I think the solution
is to use "fromIntegral" instead. GHCi<BR>> also has "fromInteger",
although I'm not quite sure why we<BR>> need this<BR>> in addition to
"fromIntegral"? (Possibly because it is a member of<BR>> Num, and it
would break too much code to remove it)<BR>><BR>> -kzm<BR>>
--<BR>> If I haven't seen further, it is by standing in the
footprints<BR>> of
giants<BR>><BR>><BR>><BR>>------------------------------------------------------------------------<BR>><BR>>_______________________________________________<BR>>Haskell
mailing
list<BR>>Haskell@haskell.org<BR>>http://www.haskell.org/mailman/listinfo/haskell<BR>><BR>><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>