← Top stories The algebra of dependent types (2025) ↗ (opens external site) 113 points by todsacerdoti 4 days ago | dotat.at | 26 comments on HN ↗ View full thread · View on Hacker News Comment thread (3) solomonb | 3 days ago | reply This is fun. His array example `Σ len: usize . Array(Int, len)` is the list polynomial functor (1 + X + X² + ...) applied to ints. Replies (1) Sharlin | 3 days ago | parent | reply I find it particularly pleasing how a list can be defined as either:1) a tagged union of homogeneous tuples of every possible size, ie. (1 + X + X² + ...), or2) the inductive form, favored in FP: either the empty list or the first element and another list, ie. 1 + X * Land how it’s easy to show that the two definitions are equivalent: L = 1 + X + X² + ... // factor out X = 1 + X (1 + X + X² + ...) // note that the (...) is the definition of L = 1 + X * L Replies (1) solomonb | 2 days ago | parent | reply Indeed! L is the least fixed point of `F(L) = 1 + X × L`. You get to the series by applying F repeatedly starting from the empty type:F(0) = 1F^2(0) = 1 + XF^3(0) = 1 + X + X^2
Replies (1)
1) a tagged union of homogeneous tuples of every possible size, ie. (1 + X + X² + ...), or
2) the inductive form, favored in FP: either the empty list or the first element and another list, ie. 1 + X * L
and how it’s easy to show that the two definitions are equivalent:
Replies (1)
F(0) = 1
F^2(0) = 1 + X
F^3(0) = 1 + X + X^2