Export Natural type from prelude

Paterson, Ross R.Paterson at city.ac.uk
Sat Jul 3 19:56:19 UTC 2021


Carter Schonwald wrote:
> This is a good point were we adding it to base. It’s already in base and widely useful!
>
> That’s a good motivation to add for fixing num and friends. But that’s not even a new problem for num instances in base. Reexport it from prelude doesn’t change that. Just improves the ergonomics for using a really nice type for both pedagogy and prototyping!
>
> I also like how natural throws an error on underflow.

That seems the wrong way round. There's lots of stuff in base, but the Prelude is part of the language definition. A higher standard should apply.

The numeric classes do indeed need fixing. When that is done, it will be necessary to preserve backwards compatibility, which is difficult but mostly possible. But adding another bad instance to the language now, including

(-) :: Natural -> Natural -> Natural

will make that more difficult. Besides, the trend for some time has been to avoid partial functions.


More information about the Libraries mailing list