Changes between Version 10 and Version 11 of Commentary/Libraries/Integer


Ignore:
Timestamp:
Jul 13, 2012 9:53:46 PM (3 years ago)
Author:
simonpj
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Libraries/Integer

    v10 v11  
    1616
    1717All Integer implementations should export the same set of types and functions from `GHC.Integer` (within whatever `integer` package you are using). These exports are used by the `base` package However, all of these types and functions must actually be defined in `GHC.Integer.Type`, so that GHC knows where to find them.
     18Specifically, the interface is this:
     19{{{
     20  data Integer
     21
     22  mkInteger :: Bool -- True <=> non-negative
     23          -> [Int]  -- Absolute value in 31 bit chunks, least significant first
     24                    -- ideally these would be Words rather than Ints, but
     25                    -- we don't have Word available at the moment.
     26          -> Integer
     27   
     28  smallInteger  :: Int# -> Integer
     29  integerTooInt :: Integer -> Int#
     30 
     31  wordToInteger :: Word# -> Integer
     32  integerToWord :: Integer -> Word#
     33
     34  -- And similarly for Int64#, Word64# on 64-bit
     35
     36  floatFromInteger  :: Integer -> Float#
     37  decodeFloatInteger :: Float# -> (# Integer, Int# #)
     38  encodeFloatInteger :: Integer -> Int# -> Float#
     39
     40  -- And similarly Double
     41
     42  plusInteger :: Integer -> Integer -> Integer
     43  -- And similarly: minusInteger, timesInteger, negateInteger,
     44  -- eqInteger, neqInteger, absInteger, signumInteger,
     45  --  leInteger, gtInteger, ltInteger, geInteger, compareInteger,
     46  --  divModInteger, quotRemInteger, quotInteger, remInteger,
     47  --  andInteger, orInteger, xorInteger, complementInteger,
     48  --  shiftLInteger, shiftRInteger,
     49  --  hashInteger,
     50}}}
    1851
    1952== How Integer is handled inside GHC  ==