Haskell performs very well on list optimization, but not the type you describe. Haskell does not have "special" list processing - they are similar to other regular Haskell types, albeit with some built-in syntactic sugar. This is nothing more special than
data List a = Nil | Cons a (List a)
will be.
Haskell optimizes lists using what is called merge foldr / build, for example, optimizes map f (filter p list) so that it does not create an intermediate list for filter , but it does both the map and the filter in the same bypass. See here for more on what fuses are, or read here for more details on how this works.
In addition, more modern Haskell array libraries use a more aggressive type of merge, which can, for example, fuse sum (map f (enumFromN 0 n)) to a tail recursive iteration from 0 to n-1 , which is basically what you want to. Explore the package, this blog post for which thread you can make, and this document for details.
source share