Problem with Infinite Lists

Wamberto Vasconcelos [email protected]
Wed, 3 Sep 2003 09:30:18 +0100


I am new in this forum, so apologies if this has been asked before. If this is 
the case, please point me to the direction of the answer and I won't bother you 

Also, could you make sure you CC your answers to me? I am not sure how long it 
takes for my subscription to be activated and I don't want to miss out on the 
action :-)

The Problem

I have defined this function to calculate the Fibonacci numbers:

all_fib :: [Float]

all_fib = 1:(1:(add_fib all_fib))
          where add_fib (x:y:rs) = (x + y):(add_fib (y:rs))

Which seems to work:

Main> take 20 all_fib

However, when I tried 

Main> filter even (take 20 all_fib)
ERROR - Illegal Haskell 98 class constraint in inferred type
*** Expression : filter even (take 20 all_fib)
*** Type       : Integral Float => [Float]

What is going on here?

Thanks in advance for any help/hint.

Wamberto Vasconcelos, PhD          [email protected]
Department of Computing Science
University of Aberdeen, Aberdeen AB24 3UE, Scotland, UK
Phone +44 (0)1224 272283           Fax +44 (0)1224 273422