fromInteger

Conversion from an Integer. An integer literal represents the application of the function fromInteger to the appropriate value of type Integer, so such literals have type (Num a) => a.
Convert from integer to ring. When {-# LANGUAGE RebindableSyntax #-} is enabled, this function is used for desugaring integer literals. This may be used to facilitate transition from Num to Ring: no need to replace 0 and 1 with one and zero or to cast numeric literals.
synonym for integralFromProxy, kept for backward compatibility
Convert number of nanoseconds to T
Replacement for fromInteger using the RebindableSyntax extension. This version of fromInteger arranges that integer literals are always of type Integer.
fromInteger is special in two ways:
  • numeric integral literals (like "42") are interpreted specifically as "fromInteger (42 :: GHC.Num.Integer)". The prelude version is used as default (or whatever fromInteger is in scope if RebindableSyntax is set).
  • The default rules in haskell2010 specify that constraints on fromInteger need to be in a form C v, where v is a Num or a subclass of Num.
So a type synonym such as type FromInteger a = FromIntegral a Integer doesn't work well with type defaulting; hence the need for a separate class.
Construct the number from the associated integer.