Tech article
Why isn't mutable a subtype of immutable, or vice versa?
No preview is available. Read the original article for the full story.
Hacker News | Sep 18, 2026 | ibobev
Automated excerpt
Namely, Liskov’s subsitution principle: a type S is a subtype of T if a value of type S can be used in every context where a value of type T is expected. All of the operations provided provided by an immutable pair are also provided by a mutable pair, so it seems like we should be able to use a mutable pair wherever an immutable pair is expected. In their terminology, mutable and immutable pairs are different types, but both can belong to a common pair type class whose operations are the original car and cdr we defined above.
Selected automatically from source text; not independently written or fact-checked. Read the original for full context.