
8 Apr
2010
8 Apr
'10
10:42 p.m.
I'd like to define an abstract type T, and some how make the following work:
3 :: T -- allow integer literals to be read as values of type T
100 :: T error: value out of bounds for type T -- place some restrictions on which integers are valid T values
To get the first feature, is my only option to make T an instance of the Num class? If so, I'd have to make fromIntegral return error for out of bounds values. Is there any problem in doing that? The only law I find mentioned for instances of Num is: abs x * signum x == x. Is this the complete requirement?