[Haskell-cafe] What is a number. (Was: Num instances for 2-dimensional types)

Henning Thielemann lemming at henning-thielemann.de
Tue Oct 6 05:37:05 EDT 2009


On Mon, 5 Oct 2009, Jason Dagit wrote:

>> 2. How can i use numeric literals to construct values, whose types are not
>> in
>> the Num class?

Numeric literals are treated as Integer or Rational, and are then 
converted with the function fromInteger or fromRational, respectively, to 
the required type. Whatever fromInteger function is in scope, will be 
used. If fromInteger is in a class other than Num (in NumericPrelude it is 
Ring, but it can be also a function that is not a class method), then 
number literals have a type like:
   2 :: MyNumClass a => a



More information about the Haskell-Cafe mailing list