
That's an interesting question. I would like to see the answer too. I can think of a completely impractical way to do it: data Quantity = 0 | 1 | 2 | 3 | ... | 65532 But of course, listing every integer seems like a dumb solution. But this gives me more confidence that there is a smart solution to your problem and we just need to find it. Daniel. aditya siram wrote:
Hi all, Is there a datatype in Haskell that can be used to represent only quantities >= 0? I got bitten by a bug because I forgot to reject an amount that was below zero after applying a decrementing operator. A simple unit test would have caught this, but I was wondering if there was some way of getting the type system to ensure this.
thanks ... -deech
------------------------------------------------------------------------
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners