
Colin Paul Adams
Ertugrul> Well, the type system allows you to create your own Ertugrul> ranged integer type. Here is a rather inflexible, but Ertugrul> working method to do it:
Ertugrul> newtype Int12 = Int12 Int deriving (Eq, Read, Show)
Ertugrul> instance Num Int12 where Int12 x + Int12 y | x+y <= 11 Ertugrul> = Int12 (x+y) | otherwise = error "Int12 addition out of Ertugrul> range" ...
That would seem to allow x = -3 and y = 13, for instance.
Not if you disallow an x = -3 and y = 13 to happen in the first place.
Haskell's module and type system allows you to do that.
Greets,
Ertugrul.
--
Key-ID: E5DD8D11 "Ertugrul Soeylemez