[Haskell-cafe] Re: Positive integers

ihope ihope127 at gmail.com
Tue Mar 28 16:32:10 EST 2006


On 3/24/06, Henning Thielemann <lemming at henning-thielemann.de> wrote:
> A new type, say Cardinal as in Modula, would document for the user of a
> function that only non-negative numbers are allowed and the function
> writer can be sure, that only non-negative numbers are passed.
>
> ...
>
>   newtype Cardinal = Cardinal Integer deriving (Show, Read, Eq, Ord, Ix)
>   newtype Card     = Card     Int     deriving (Show, Read, Eq, Ord, Ix)

Has anybody tried to implement arbitrary- and machine-size natural
numbers (Cardinal and Card, respectively) in GHC using unboxed types?
It should be just a matter of tweaking Int, Integer and Word a bit.


More information about the Haskell-Cafe mailing list