[Hugs-users] the standard function enumFrom

Paqui Lucio paqui.lucio at ehu.es
Mon Oct 25 11:12:45 EDT 2010


Hi,
Given the following enumerated type (as an example)

data P = A | B | C | D | E 
         deriving (Show,Enum)

and the Prelude definition: 
 	    enumFrom x  = map toEnum [ fromEnum x ..]

I guess that  the two expressions 
	1) (map toEnum [ fromEnum A ..]) :: [P]
	2)  enumFrom A 
should produces the same result, say 
	[A,B,C,D,E] :: [P] 

However, the expression 1)  produces an error as a consequence of trying to
apply toEnum to the number 5.
¿Why the expression 2) doesn't not produce the same error?
¿Does Hugs not apply the definition in the Prelude for evaluating the
expression 2)?
There should be something that I'm missing in this computation. 
Some hints?

Thanks in advance,
Paqui

--------------------------------- 
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/20101025/a5fbd9b1/attachment.html


More information about the Hugs-Users mailing list