Skip to content

Data.Lazy.List is too strict #4

@natefaubion

Description

@natefaubion
a :: List Number
a = Cons 1 $ defer \_ -> ((+) 1) <$> a
> take 5 a
RangeError: Maximum call stack size exceeded

Whereas:

map :: forall a b. (a -> b) -> List a -> List b
map f (Cons x thunk) = Cons (f x) $ defer \_ -> map f $ force thunk
map f Nil = Nil

a' :: List Number
a' = Cons 1 $ defer \_ -> map ((+) 1) a'
> take 5 a'
List(1, 2, 3, 4, 5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions