Add a note about (a, List a) for non-empty lists
commitea5c662995b0997264032fb1b251400e70c4ba82
authorEvan Czaplicki <evancz@users.noreply.github.com>
dateThu 23 Nov 2017, 19:53 (9 years ago)
parent7c33c13
hints/missing-patterns.md+2
@@ -138,3 +138,5 @@ last list =
138138```
139139
140140This is nice because it lets users know that there might be a failure, so they can recover from it however they want.
141+
142+> An alternative would be to represent a non-empty list explicitly. For example, the type `(a, List a)` guarantees that there is at least one `a` value, so you could alternatively create a function `last : (a, List a) -> a` or `last : a -> List a -> a` to demand at least one item.