the built-in function enumFrom

"Paqui Lucio" <[email protected]> Thu, 29 Oct 2009 11:06:31 +0100
Newsgroups gmane.comp.lang.haskell.hugs.user
Message-ID <2C6E8CB5494947528D03DE55E690B2BD@SIPC64>
This is a multi-part message in MIME format.

--===============1397691507==
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_0037_01CA5887.DEC8A0C0"

This is a multi-part message in MIME format.

------=_NextPart_000_0037_01CA5887.DEC8A0C0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,=20
In Prelude.hs you can find the definition=20
enumFrom x =3D map toEnum [ fromEnum x ..]=20
Load a file.hs of just one line:=20
data TBool =3D Falsity | Undefined |Truth deriving (Enum, Show)=20
Then, I evaluate=20
enumFrom Falsity=20
and, as expected, it gives=20
[Falsity,Undefined,Truth]=20
However, the expression=20
map toEnum [ fromEnum Falsity ..]=20
gives first an ambiguity problem and then the problem I expected=20
Main> map toEnum [ fromEnum Falsity ..]=20
ERROR - Unresolved overloading=20
*** Type : Enum a =3D> [a]=20
*** Expression : map toEnum (enumFrom (fromEnum Falsity))=20
Main> map toEnum [ fromEnum Falsity ..]::[TBool]=20
[Falsity,Undefined,Truth,=20
Program error: {_toEnum TBool_Falsity 3}=20
(98 reductions, 301 cells)=20
Why the function enumFrom works perfectly in spite of its erroneous
definition?=20
Thanks in advance,=20
Paqui=20
P.D.=20
I am using the=20
|| || || || || || ||__ Hugs 98: Based on the Haskell 98 standard=20
||___|| ||__|| ||__|| __|| Copyright (c) 1994-2002=20
||---|| ___|| World Wide Web: http://haskell.org/hugs=20
|| || Report bugs to: [email protected]=20
|| || Version: Nov 2002=20


---------------------------------=20
Paqui Lucio                               =20
Dpto de LSI                   =20
Facultad de Inform=E1tica
Paseo Manuel de Lardizabal, 1
20080-San Sebasti=E1n
SPAIN
---------------------------------
e-mail: [email protected]
Tfn: (+34) (9)43 015049 =20
Fax: (+34) (9)43 015590
Web: http://www.sc.ehu.es/paqui
---------------------------------


------=_NextPart_000_0037_01CA5887.DEC8A0C0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
6.5.7036.0">
<TITLE>the built-in function enumFrom</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><SPAN LANG=3D"es"><FONT FACE=3D"Times New Roman">Hi,<BR>
In Prelude.hs you can find the definition<BR>
enumFrom x =3D map toEnum [ fromEnum x ..]<BR>
Load a file.hs of just one line:<BR>
data TBool =3D Falsity | Undefined |Truth deriving (Enum, Show)<BR>
Then, I evaluate<BR>
enumFrom Falsity<BR>
and, as expected, it gives<BR>
[Falsity,Undefined,Truth]<BR>
However, the expression<BR>
map toEnum [ fromEnum Falsity ..]<BR>
gives first an ambiguity problem and then the problem I expected =
</FONT></SPAN>

<BR><SPAN LANG=3D"es"><FONT FACE=3D"Times New Roman">Main&gt; map toEnum =
[ fromEnum Falsity ..]<BR>
ERROR - Unresolved overloading<BR>
*** Type : Enum a =3D&gt; [a]<BR>
*** Expression : map toEnum (enumFrom (fromEnum Falsity)) </FONT></SPAN>

<BR><SPAN LANG=3D"es"><FONT FACE=3D"Times New Roman">Main&gt; map toEnum =
[ fromEnum Falsity ..]::[TBool]<BR>
[Falsity,Undefined,Truth,<BR>
Program error: {_toEnum TBool_Falsity 3}<BR>
(98 reductions, 301 cells) </FONT></SPAN>

<BR><SPAN LANG=3D"es"><FONT FACE=3D"Times New Roman">Why the function =
enumFrom works perfectly in spite of its erroneous definition?<BR>
Thanks in advance,<BR>
Paqui </FONT></SPAN>

<BR><SPAN LANG=3D"es"><FONT COLOR=3D"#0000FF" FACE=3D"Times New =
Roman">P.D. </FONT></SPAN>

<BR><SPAN LANG=3D"es"><FONT COLOR=3D"#000000" FACE=3D"Times New Roman">I =
am using the<BR>
|| || || || || || ||__ Hugs 98: Based on the Haskell 98 standard<BR>
||___|| ||__|| ||__|| __|| Copyright (c) 1994-2002<BR>
||---|| ___|| World Wide Web:</FONT> </SPAN><A =
HREF=3D"http://haskell.org/hugs"><SPAN LANG=3D"es"><U></U><U><FONT =
COLOR=3D"#0000FF" FACE=3D"Times New =
Roman">http://haskell.org/hugs</FONT></U></SPAN></A><SPAN =
LANG=3D"es"><FONT COLOR=3D"#000000" FACE=3D"Times New Roman"><BR>
|| || Report bugs to: [email protected]<BR>
|| || Version: Nov 2002</FONT> </SPAN>
</P>
<BR>

<P><SPAN LANG=3D"es"><FONT SIZE=3D2 FACE=3D"Courier =
New">--------------------------------- </FONT></SPAN>

<BR><SPAN LANG=3D"es"><FONT SIZE=3D2 FACE=3D"Courier New">Paqui =
Lucio&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN>

<BR><SPAN LANG=3D"es"><FONT SIZE=3D2 FACE=3D"Courier New">Dpto de =
LSI&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN>

<BR><SPAN LANG=3D"es"><FONT SIZE=3D2 FACE=3D"Courier New">Facultad de =
Inform=E1tica</FONT></SPAN>

<BR><SPAN LANG=3D"es"><FONT SIZE=3D2 FACE=3D"Courier New">Paseo Manuel =
de Lardizabal, 1</FONT></SPAN>

<BR><SPAN LANG=3D"es"><FONT SIZE=3D2 FACE=3D"Courier New">20080-San =
Sebasti=E1n</FONT></SPAN>

<BR><SPAN LANG=3D"es"><FONT SIZE=3D2 FACE=3D"Courier =
New">SPAIN</FONT></SPAN>

<BR><SPAN LANG=3D"es"><FONT SIZE=3D2 FACE=3D"Courier =
New">---------------------------------</FONT></SPAN>

<BR><SPAN LANG=3D"es"><FONT SIZE=3D2 FACE=3D"Courier New">e-mail: =
[email protected]</FONT></SPAN>

<BR><SPAN LANG=3D"es"><FONT SIZE=3D2 FACE=3D"Courier New">Tfn: (+34) =
(9)43 015049&nbsp; </FONT></SPAN>

<BR><SPAN LANG=3D"es"><FONT SIZE=3D2 FACE=3D"Courier New">Fax: (+34) =
(9)43 015590</FONT></SPAN>

<BR><SPAN LANG=3D"en-gb"><FONT SIZE=3D2 FACE=3D"Courier New">Web: =
</FONT></SPAN><A HREF=3D"http://www.sc.ehu.es/paqui"><SPAN =
LANG=3D"en-gb"><U><FONT COLOR=3D"#0000FF" SIZE=3D2 FACE=3D"Courier =
New">http://www.sc.ehu.es/paqui</FONT></U></SPAN></A><SPAN =
LANG=3D"en-gb"></SPAN>

<BR><SPAN LANG=3D"es"><FONT SIZE=3D2 FACE=3D"Courier =
New">---------------------------------</FONT></SPAN><SPAN =
LANG=3D"es"></SPAN>
</P>

</BODY>
</HTML>
------=_NextPart_000_0037_01CA5887.DEC8A0C0--


--===============1397691507==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Hugs-Users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/hugs-users

--===============1397691507==--