[Haskell-beginners] A Quantity Type - Integer without the Negative
#'s
Daniel Carrera
daniel.carrera at theingots.org
Sat May 9 03:37:53 EDT 2009
Magnus Therning wrote:
> 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.
>
> Maybe Word32 (or one of it's siblings) would do? It's basically the
> same as 'unsigned int' in C, so it can under- and over-flow.
What's under-flow?
More information about the Beginners
mailing list