The other answers are pretty idiomatic to F#, but here is a way to make it impossible to construct a zero value (at a slight inconvenience to the caller):
type Digit = | One = 1 | Two = 2 | Three = 3 | Four = 4 | Five = 5 | Six = 6 | Seven = 7 | Eight = 8 | Nine = 9 type NonZero private(ones, tens, hundreds, thousands, ten_thousands) = static let f (n : Digit) = int n member val num = f(ones) + 10 * tens + 100 * hundreds + 1000 * thousands + 10000 * ten_thousands new (ten_thousands, thousands, hundreds, tens, ones) = NonZero(ones, f tens, f hundreds, f thousands, f ten_thousands) new (thousands, hundreds, tens, ones) = NonZero(ones, f tens, f hundreds, f thousands, 0) new (hundreds, tens, ones) = NonZero(ones, f tens, f hundreds, 0, 0) new (tens, ones) = NonZero(ones, f tens, 0, 0, 0) new (ones) = NonZero(ones, 0, 0, 0, 0)
Here is how you would construct, say, the number 123:
let k = new NonZero(Digit.One, Digit.Two, Digit.Three)
And to retrieve the value:
let l = k.num //l is 123 : int
Hence, it is impossible to pass a zero value to a function with type NonZero -> 'a.