It just seemed to me that the F # generators did not seem to accept constant values ββas "template parameters".
Suppose you want to create a RangedInt type such that it behaves like an int, but is guaranteed to contain only a subrange of integer values.
A possible approach would be a discriminatory union similar to:
type RangedInt = | Valid of int | Invalid
But this also does not work, since there is no "specific type of storage of information about the range." And 2 instances of RangedInt must be of a different type if the range is also different.
Being a bit more infected with C ++, it will look like:
template<int low,int high> class RangedInteger { ... };
Now the question arises two times:
- Am I missing something and are there constant values ββfor F # generators?
- If I hadn't missed this, what would be the idiomatic way to execute such a
RangedInt<int,int> in F #?
Finding Tomas Petricek's blog about custom numeric types , the equivalent of my question for this blog article: What if he didn't IntegerZ5 , and IntegerZn<int> custom type family?
source share