[Hugs-users] the built-in function enumFrom

Paqui Lucio paqui.lucio at ehu.es
Thu Oct 29 06:06:31 EDT 2009


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


--------------------------------- 
Paqui Lucio                                
Dpto de LSI                    
Facultad de Informática
Paseo Manuel de Lardizabal, 1
20080-San Sebastián
SPAIN
---------------------------------
e-mail: paqui.lucio at ehu.es
Tfn: (+34) (9)43 015049  
Fax: (+34) (9)43 015590
Web: http://www.sc.ehu.es/paqui
---------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/hugs-users/attachments/20091029/3bdf8463/attachment-0001.html


More information about the Hugs-Users mailing list