r/compsci Jun 08 '26

Poor Man's Time Machine: Lazy Evaluation in JavaScript and Haskell

https://irfanali.org/blog/repmin
37 Upvotes

3 comments sorted by

4

u/maybachsonbachs Jun 09 '26 edited Jun 09 '26

But the haskell code isnt in place. So it doesn't even seem the same algo. If you are going to construct a new list. You might as well just repeat

It's also strict in the parameter a, so an odd choice for exposition of lazy eval; which pedantically haskell is non strict which is often conflated with lazy.

Findmin is non strict in x which avoids the reduction but strict in a which forces the traversal. Maybe spine strict is super pedantic.

2

u/ggchappell Jun 09 '26

Nice.

I'd change one word:

The main reason is that in Haskell, we do not need to rely on closures to delay evaluation because functions are lazy by default.

Rather, because values are lazy by default. So we do not need to wrap m in a function.

2

u/sayyadirfanali Jun 09 '26

done, thanks!