[Haskell-cafe] Recursion problem in infinite list model

Hans Aberg haberg at math.su.se
Thu Mar 27 11:12:47 EDT 2008


On 27 Mar 2008, at 15:58, Miguel Mitrofanov wrote:

> Hmmm, seems like your (-+) is not lazy enough.
...
> You can fix it by defining (-+) as
>
> x -+ ~(List y) = ...

Yes, this has been pointed out...

>
> Since pattern matching is strict by default, you have
>
> anything -+ (_|_) = (_|_)
>
> Therefore, the function, which is constantly (_|_), is a fixed  
> point for the equation defining h. In other words, if you define
>
> h' x = undefined
>
> then you have
>
> h' x = (-+) anything (h anything)
>
> in particular,
>
> h' x = (-+) (first x) (h (rest x))

But additional explanation is helpful. Thank you.

   Hans Aberg




More information about the Haskell-Cafe mailing list