Delete number newtypes
Closed this issue · 3 comments
Positive Negative NonNegative NonZero ect. newtypes encourage bad coding practices while in StrongCheck. Please delete them.
That said, there may be value to having a repo with only newtypes like this with enforcement using Maybe to ensure that the number can only be of that type. Complete with arbitrary instances.
What bad coding practices?
Well, mainly that if you are testing a function which expects Number, and you are forced into using Positive because your function cannot handle negative numbers, then you should probably have more strongly typed your function, with a custom (library?) Positive type, with smart constructors. In that case, you can easily define your own Arbitrary for your own custom Positive type. Basically the only case in which you would use Positive, etc., are cases which are necessarily unsafe, because they don't test the full range of values that it's actually possible to pass the functions you're testing.
Right, you could hook it up so the only way to get a Positive type is through a function that has a codomain of Maybe Positive. Then the type system can be counted on to enforce that the number is positive. (sort of a way to have dependent types without real dependent types)