Re:It never makes sense to use foldl on lists in Haskell (2019)
by Tarean on Saturday March 21, 2020 @09:20AM
(#22646302)
Haskell is lazy, all data structures work this way unless specifically annotated otherwise.
Within standard haskell 2010 it is hard to declare a linked list that doesn't work this way.
It is also worth noting that haskell has library specified fusion rules so the closure isn't even allocated most of the time. So
sum (take 10 [0..])
compiles into an allocation free loop. I will give you that this isn't a linked list anymore, though.
It is also worth noting that haskell has library specified fusion rules so the closure isn't even allocated most of the time. So
compiles into an allocation free loop. I will give you that this isn't a linked list anymore, though.