2 ms·
> Are Haskell lists actually implemented as linked lists? Yes, the type "[]" from the Prelude is a linked list. > I would have thought they were compiled as "
by tome 4y ago
> Are Haskell lists actually implemented as linked lists?
Yes, the type "[]" from the Prelude is a linked list.
> I would have thought they were compiled as "array lists" like Python (arrays of pointers, but with extra space pre-allocated to make extending cheap)
No, and that doesn't quite work for immutable types, since there's nothing you can do with the "extra space pre-allocated". You can't mutate it! Nonetheless, rope-like structures will work fine, and there are surely plenty of them floating around.