
28 Mar
2006
28 Mar
'06
4:32 p.m.
On 3/24/06, Henning Thielemann
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.