[Haskell-cafe] Re: [Haskell] Recursive definition of fibonacci with Data.Vector

Alexander Solla ajs at 2piix.com
Sun Mar 7 20:17:18 EST 2010

On Mar 7, 2010, at 12:56 PM, Don Stewart wrote:

> In fact, infinite vectors make no sense, as far as I can tell -- these
> are fundamentally bounded structures.

Fourier analysis?  Functional analysis?  Hamel bases in Real  
analysis?  There are lots of infinite dimensional vector spaces out  

> GHC even optimizes it to:
>    fib = fib

Sounds like an implementation bug, not an infinite dimensional vector  
space bug.  My guess is that strictness is getting in the way, and  
forcing what would be a lazy call to fib in the corresponding list  
code -- fib = 0 : 1 : (zipWith (+) fib (tail fib)) -- into a strict one.

In fact, I'm pretty sure that's what the problem is:

data Vector a = Vector {-# UNPACK #-} !Int
                        {-# UNPACK #-} !Int
                        {-# UNPACK #-} !(Array a)

The !'s mean "strict" right?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100307/ca4da1e8/attachment.html

More information about the Haskell-Cafe mailing list