3 ms·
You can have types in haskell that represent finite length lists. Here's a blog post giving an overview of several methods of doing so (and several examples of
by almostdeadguy 7y ago
You can have types in haskell that represent finite length lists. Here's a blog post giving an overview of several methods of doing so (and several examples of libraries in the wild that provide this): https://blog.jle.im/entry/fixed-length-vector-types-in-haskell.html https://blog.jle.im/entry/fixed-length-vector-types-in-haske...
There's a tradeoff here between generality and how important it is to encode all invariants about a piece of data. Many haskell list processing functions are expressed in terms of right folds, which makes infinite lists fairly unproblematic to work with so long as only part of the list is demanded in the end, however for some cases you may want the type system to ensure you can't receive an infinite list.