r/functionalprogramming • • Jun 28 '24

Question Does Lazy Evaluation have a Future?

In Haskell it is used for deforestation to keep the stack low. But after some experience with it, it is simply a problematic concept.
UPDATE: What do you think about a concept with buds?
Buds that change from unbound to bound via a side effect,
which can be checked beforehand with isbound. Wouldn't a concept with buds be much more flexible.

2 Upvotes

20 comments sorted by

View all comments

Show parent comment

2

u/quiteamess Jun 29 '24

Yeah, I see your point. It would be nice if the type would ensure that the program terminates. But this is not the case at all in Haskell. It is possible to define infinite recursion and there is undefined. So there is not totality checking anyways in Haskell, so I don’t think this is a particular concern about laziness.

If you want to enforce this kind of corrections in the type system you will need dependent types. Idris is not lazy by default, but I think these concerns are orthogonal.

2

u/faiface Jun 29 '24

We don’t need everything or nothing when it comes to termination. Preventing various things one by one is also a benefit. Even without any totality checking, making lists strict and finite will move the hang up to the construction of the list instead of whatever place the list is consumed. Also it helps with thinking about the program. You instatly see what’s a list and what’s a stream, so you know what you can with them. In Haskell, you can easily make the mistake of thinking a list is finite, when it actually isn’t or think a function accepts an infinite list when it doesn’t, or not in all cases.

3

u/quiteamess Jun 30 '24

First of all, Haskell is a research project that started how far you could get with pure, lazy, functional programming. If you want to explore a new paradigm you have to stick to it.

We are re-hashing a discussion that was going on in the nineties. Hughes argued that laziness gives programmers a “glue” to build modular programs. He concludes that “[..] lazy evaluation is too important to be relegated to second class citizenship”. Haskell is the research tool to test that idea.

When you follow the citations of the paper you see that there are about 1500 citations. For example the paper on QuickCheck has an explicit discussion about lazy evaluation (6.5). And indeed they are raising similar concerns that you have raised. But if termination checking is important for you, maybe Idris or one of the other research languages is a better choice.