purescript/purescript-lists

Bug of Data.List.Lazy take

ibara1454 opened this issue · 1 comments

My English isn't good so feel free to ask me if there is anything unclear.

Problem

I found a problem that take evaluate the value too early.
It always evaluate the next value which we don't need.

To show this, I construct a lazy constructed list (elements in the list will be constructed only when they are needed), and use spy to print the value when the it is evaluated.

Actually

bug_take

Desire

> take 0 lazyl
fromStrict (Nil)

> take 1 lazyl
1
fromStrict ((Cons 1 Nil))

And I have made a pull request of this.
You can use it if you think it is OK.