Problem/background
Many of the functions related to ranges in base are exclusive on the upper bound, which always makes me think a bit harder, and I suspect that it would be surprising to newcomers. For example, I think that most people looking at the code Random.natIn 1 2 would expect it to generate 1 or 2 with equal probability, but in fact it will always generate 1.
The exclusive upper bound is also problematic when you want your range to include the max value (example: maxNat). I don't think that there's any simple way to achieve this functionality with exclusive ranges.
There are also some inconsistencies in base. For example Random.natIn lower upper is exclusive in upper but Text.patterns.charRange is inclusive in upper.
Proposed solution
I think that ranges should generally be inclusive and that exclusive ranges should be explicit in the name. So Random.natIn lower upper would include upper and Random.nat.range.closed lower upperExcluded (or whatever the name would be) would exclude upperExcluded.
Problem/background
Many of the functions related to ranges in base are exclusive on the upper bound, which always makes me think a bit harder, and I suspect that it would be surprising to newcomers. For example, I think that most people looking at the code
Random.natIn 1 2would expect it to generate1or2with equal probability, but in fact it will always generate1.The exclusive upper bound is also problematic when you want your range to include the max value (example:
maxNat). I don't think that there's any simple way to achieve this functionality with exclusive ranges.There are also some inconsistencies in base. For example
Random.natIn lower upperis exclusive in upper butText.patterns.charRangeis inclusive in upper.Proposed solution
I think that ranges should generally be inclusive and that exclusive ranges should be explicit in the name. So
Random.natIn lower upperwould includeupperandRandom.nat.range.closed lower upperExcluded(or whatever the name would be) would excludeupperExcluded.