Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Data should be strict, logic should be lazy. It's the programmer's job do use judgment to decide which parts of which data structures are data vs logic. One heuristic is that anything recursive should be lazy, and the rest strict

    (Tree = Leaf !Int | Node [Tree]))
and if you really need a lazy int in there, delay it yourself using partially applied functions.


Yea, I agree with this and it's a good pattern in the case you know the type is "Int" or some other primitive. But Haskell thrives on type variables and data structures are usually defined generically making it more complicated.

From what I remember to get around this one would use a type class to define a data structure's operations, and then provide specific implementations of that data structure for specific strict data types. But that is more complicated than just having the compiler apply strictness everywhere.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: