Přemysl Šťastný
Přemysl Šťastný

Reputation: 1832

Why is Data.Text.Lazy needed? Couldn't strict chunks of a lazy structure be made by a compiler optimizer?

I wonder whether a Haskell compiler optimizer couldn't generally split larger lazy data structures into smaller strict pieces to gain more performant programs.

For example, by Data.Text.Lazy we make the same behavior. Strict chunks of Data.Text in larger lazy structures. If this optimization would be possible, could we just use String instead with the same performance and make the code nicer?

Is there any conceptual/theoretical reason, why this optimization can't be made, or it is just practically so hard, nobody implemented it yet? Is it the current issue among GHC developers?

Upvotes: 2

Views: 686

Answers (1)

Daniel Wagner
Daniel Wagner

Reputation: 152757

So my question is, what is Data.Text.Lazy good for, if String structure using the compiler optimizations (if they exist) should behave just like it?

If String behaved just like Data.Text.Lazy.Text, then there would indeed be no point. But it doesn't, and there are no inklings that it might in the near future.

Upvotes: 4

Related Questions