serokell / universum

:milky_way: Prelude written in @Serokell
MIT License
176 stars 26 forks source link

Return `Natural` in functions that return the size of the container #245

Open DMozhevitin opened 3 years ago

DMozhevitin commented 3 years ago

The length function from Universum.Container.Class module returns Int, and we can return Natural there and make it type-safe because it is obvious that the size of the container is always non-negative. It will avoid unnecessary fromIntegral @Int @Natural conversions that seem unsafe at first glance.

If there are functions with a similar invariant that also return Int, they should also be changed.