[fix up library to pass the more strigent typechecking
John Meacham <john@repetae.net>**20120205082156
 Ignore-this: 3c5499a310f582ae00991fee63b32ca6
] adddir ./lib/jhc/Jhc/Class
move ./lib/jhc/Jhc/Num.hs ./lib/jhc/Jhc/Class/Num.hs
move ./lib/jhc/Jhc/Order.hs ./lib/jhc/Jhc/Class/Ord.hs
hunk ./Makefile.am 210
+	rm -f -- `find ~/.jhc/cache -name \*.ho -print`
hunk ./lib/base/Data/Ix.hs 9
+import Jhc.Tuples
hunk ./lib/jhc/Jhc/ACIO.hs 8
-
hunk ./lib/jhc/Jhc/ACIO.hs 20
-
hunk ./lib/jhc/Jhc/ACIO.hs 66
-
hunk ./lib/jhc/Jhc/Array.hs 8
-
-
hunk ./lib/jhc/Jhc/Class/Num.hs 2
-module Jhc.Num(module Jhc.Num, Ratio(..)) where
+module Jhc.Class.Num where
hunk ./lib/jhc/Jhc/Class/Num.hs 17
-numerator, denominator  :: Ratio a -> a
-numerator (x :% _)      =  x
-denominator (_ :% y)    =  y
-
hunk ./lib/jhc/Jhc/Class/Num.hs 67
-
-
-fromIntegral   :: (Integral a, Num b) => a -> b
-fromIntegral x =  fromInteger (toInteger x)
-
-realToFrac     :: (Real a, Fractional b) => a -> b
-realToFrac x   =  fromRational (toRational x)
-
-{-# RULES
-"realToFrac/toRational"     realToFrac = toRational
-"realToFrac/fromRational"   realToFrac = fromRational
-"realToFrac/toDouble"       realToFrac = toDouble
-"realToFrac/fromDouble"     realToFrac = fromDouble
-#-}
-
-{-# RULES
-"fromIntegral/Int"          fromIntegral = (id :: Int -> Int)
-"fromIntegral/Integer"      fromIntegral = (id :: Integer -> Integer)
-"fromIntegral/toInt"        fromIntegral = toInt
-"fromIntegral/fromInt"      fromIntegral = fromInt
-"fromIntegral/toInteger"    fromIntegral = toInteger
-"fromIntegral/fromInteger"  fromIntegral = fromInteger
-#-}
-
-
-{-# INLINE subtract #-}
-subtract         :: (Num a) => a -> a -> a
-subtract         =  flip (-)
-
-{-# INLINE even #-}
-{-# INLINE odd #-}
-
-even, odd        :: (Integral a) => a -> Bool
-even n           =  n `rem` 2 == 0
-odd              =  not . even
hunk ./lib/jhc/Jhc/Class/Ord.hs 1
-{-# OPTIONS_JHC -fm4 -fno-prelude -fffi #-}
+module Jhc.Class.Ord where
hunk ./lib/jhc/Jhc/Class/Ord.hs 3
-module Jhc.Order(
-    Bool(..),
-    Ordering(..),
-    Eq(..),
-    Ord(..),
-    (&&),
-    (||),
-    not,
-    otherwise
-    ) where
-
-import Jhc.Basics
-import Jhc.Prim.Bits
-import Jhc.Prim.Prim
hunk ./lib/jhc/Jhc/Class/Ord.hs 4
-
-m4_include(Jhc/Order.m4)
-
-deriving instance Eq Bool
-deriving instance Ord Bool
-deriving instance Eq Ordering
-deriving instance Ord Ordering
+import Jhc.Prim.Prim
hunk ./lib/jhc/Jhc/Class/Ord.hs 25
-                | otherwise = GT
+                | True = GT
hunk ./lib/jhc/Jhc/Class/Ord.hs 27
-    x <= y  = compare x y /= GT
-    x <  y  = compare x y == LT
-    x >= y  = compare x y /= LT
-    x >  y  = compare x y == GT
+    x <= y  = case compare x y of GT -> False; _ -> True
+    x <  y  = case compare x y of LT -> True; _ -> False
+    y >= x  = case compare x y of GT -> False; _ -> True
+    y >  x  = case compare x y of LT -> True; _ -> False
hunk ./lib/jhc/Jhc/Class/Ord.hs 34
-            | otherwise =  x
+            | True =  x
hunk ./lib/jhc/Jhc/Class/Ord.hs 36
-            | otherwise =  y
-
-instance Eq () where
-    () == () = True
-    () /= () = False
-
-instance Ord () where
-    () <= () = True
-    () <  () = False
-    () >= () = True
-    () >  () = False
-    max () () = ()
-    min () () = ()
-    compare () () = EQ
-
-instance Eq a => Eq [a] where
-    [] == [] = True
-    (x:xs) == (y:ys) | x == y = xs == ys
-    _ == _ = False
-
-instance Ord a => Ord [a] where
-    compare (x:xs) (y:ys) = case compare x y of
-        EQ -> compare xs ys
-        z -> z
-    compare [] [] = EQ
-    compare [] _ = LT
-    compare _ [] = GT
-
-    _ < [] = False
-    [] < _ = True
-    (x:xs) < (y:ys) = if x == y then xs < ys else x < y
-
-    x > y = y < x
-
-    x >= y = not (x < y)
-    x <= y = not (y < x)
-
-INST_EQORDER(Char,Char,Char_,U)
-INST_EQORDER(Int,,Int,)
-INST_EQORDER(Integer,,Integer,)
-
-infixr 3  &&
-infixr 2  ||
-
-{-# INLINE (&&), (||), not, otherwise #-}
-(&&), (||)       :: Bool -> Bool -> Bool
-True  && x       =  x
-False && _       =  False
-True  || _       =  True
-False || x       =  x
-
-not              :: Bool -> Bool
-not x = if x then False else True
-
-otherwise        :: Bool
-otherwise        =  True
+            | True =  y
hunk ./lib/jhc/Jhc/Float.hs 23
+import Prelude.Text
hunk ./lib/jhc/Jhc/Hole.hs 29
-
hunk ./lib/jhc/Jhc/Inst/Enum.hs 13
+import Jhc.Type.C
hunk ./lib/jhc/Jhc/Inst/Enum.hs 48
+ENUMINST(CChar)
+BOUNDED(CChar)
+ENUMINST(CSChar)
+BOUNDED(CSChar)
+ENUMINST(CUChar)
+UBOUNDED(CUChar)
+ENUMINST(CSize)
+BOUNDED(CSize)
+ENUMINST(CInt)
+BOUNDED(CInt)
+ENUMINST(CUInt)
+UBOUNDED(CUInt)
+ENUMINST(CWchar)
+UBOUNDED(CWchar)
+
hunk ./lib/jhc/Jhc/Inst/Num.hs 13
-import Foreign.C.Types
+import Jhc.Inst.Enum
+import Prelude.Text
+import Jhc.Type.C
hunk ./lib/jhc/Jhc/Inst/Num.hs 52
-SIGNED(CUInt)
+UNSIGNED(CUInt)
hunk ./lib/jhc/Jhc/Inst/Show.hs 5
-import Jhc.Inst.Order
hunk ./lib/jhc/Jhc/Inst/Show.hs 8
+import Jhc.Inst.Order
hunk ./lib/jhc/Jhc/Inst/Show.hs 12
+import Jhc.Type.C
hunk ./lib/jhc/Jhc/Inst/Show.hs 59
+instance Show IntMax where
+    showsPrec p x = showsPrec p (fromIntegral x :: Integer)
+
+instance Show CSize where
+    showsPrec p x = showsPrec p (fromIntegral x :: Integer)
+instance Show CInt where
+    showsPrec p x = showsPrec p (fromIntegral x :: Integer)
hunk ./lib/jhc/Jhc/Inst/Show.hs 67
+instance Show CChar where
+    showsPrec p x = showsPrec p (fromIntegral x :: Int)
+instance Show CSChar where
+    showsPrec p x = showsPrec p (fromIntegral x :: Int)
+instance Show CUChar where
+    showsPrec _ x = showWord (fromIntegral x :: Word)
+instance Show CUInt where
+    showsPrec _ x = showWord (fromIntegral x :: Word)
+instance Show CWchar where
+    showsPrec _ x = showWord (fromIntegral x :: Word)
hunk ./lib/jhc/Jhc/JumpPoint.hs 13
-
hunk ./lib/jhc/Jhc/Maybe.hs 43
-
addfile ./lib/jhc/Jhc/Num.hs
hunk ./lib/jhc/Jhc/Num.hs 1
+module Jhc.Num(module Jhc.Num, module Jhc.Class.Num,Ratio(..)) where
+
+import Jhc.Class.Num
+import Jhc.Class.Ord
+import Jhc.Type.Float
+import Jhc.Basics
+
+numerator, denominator  :: Ratio a -> a
+numerator (x :% _)      =  x
+denominator (_ :% y)    =  y
+
+fromIntegral   :: (Integral a, Num b) => a -> b
+fromIntegral x =  fromInteger (toInteger x)
+
+realToFrac     :: (Real a, Fractional b) => a -> b
+realToFrac x   =  fromRational (toRational x)
+
+{-# RULES
+"realToFrac/toRational"     realToFrac = toRational
+"realToFrac/fromRational"   realToFrac = fromRational
+"realToFrac/toDouble"       realToFrac = toDouble
+"realToFrac/fromDouble"     realToFrac = fromDouble
+#-}
+
+{-# RULES
+"fromIntegral/Int"          fromIntegral = (id :: Int -> Int)
+"fromIntegral/Integer"      fromIntegral = (id :: Integer -> Integer)
+"fromIntegral/toInt"        fromIntegral = toInt
+"fromIntegral/fromInt"      fromIntegral = fromInt
+"fromIntegral/toInteger"    fromIntegral = toInteger
+"fromIntegral/fromInteger"  fromIntegral = fromInteger
+#-}
+
+{-# INLINE subtract #-}
+subtract         :: (Num a) => a -> a -> a
+subtract         =  flip (-)
+
+{-# INLINE even #-}
+{-# INLINE odd #-}
+
+even, odd        :: (Integral a) => a -> Bool
+even n           =  n `rem` 2 == 0
+odd  n           =  n `rem` 2 /= 0
addfile ./lib/jhc/Jhc/Order.hs
hunk ./lib/jhc/Jhc/Order.hs 1
+{-# OPTIONS_JHC -fm4 -fno-prelude -fffi #-}
+module Jhc.Order(
+    module Jhc.Class.Ord,
+    Bool(..),
+    Ordering(..),
+    Eq(..),
+    Ord(..),
+    (&&),
+    (||),
+    not,
+    otherwise
+) where
+
+import Jhc.Basics
+import Jhc.Prim.Bits
+import Jhc.Prim.Prim
+
+import Jhc.Class.Ord
+
+m4_include(Jhc/Order.m4)
+
+deriving instance Eq Bool
+deriving instance Ord Bool
+deriving instance Eq Ordering
+deriving instance Ord Ordering
+
+instance Eq () where
+    () == () = True
+    () /= () = False
+
+instance Ord () where
+    () <= () = True
+    () <  () = False
+    () >= () = True
+    () >  () = False
+    max () () = ()
+    min () () = ()
+    compare () () = EQ
+
+instance Eq a => Eq [a] where
+    [] == [] = True
+    (x:xs) == (y:ys) | x == y = xs == ys
+    _ == _ = False
+
+instance Ord a => Ord [a] where
+    compare (x:xs) (y:ys) = case compare x y of
+        EQ -> compare xs ys
+        z -> z
+    compare [] [] = EQ
+    compare [] _ = LT
+    compare _ [] = GT
+
+    _ < [] = False
+    [] < _ = True
+    (x:xs) < (y:ys) = if x == y then xs < ys else x < y
+
+    x > y = y < x
+
+    x >= y = not (x < y)
+    x <= y = not (y < x)
+
+INST_EQORDER(Char,Char,Char_,U)
+INST_EQORDER(Int,,Int,)
+INST_EQORDER(Integer,,Integer,)
+
+infixr 3  &&
+infixr 2  ||
+
+{-# INLINE (&&), (||), not, otherwise #-}
+(&&), (||)       :: Bool -> Bool -> Bool
+True  && x       =  x
+False && _       =  False
+True  || _       =  True
+False || x       =  x
+
+not              :: Bool -> Bool
+not x = if x then False else True
+
+otherwise        :: Bool
+otherwise        =  True
hunk ./lib/jhc/Jhc/Show.hs 40
-
hunk ./lib/jhc/Jhc/Show.hs 55
-
hunk ./lib/jhc/Jhc/Show.hs 59
-
hunk ./lib/jhc/Jhc/Tuples.hs 13
-
hunk ./lib/jhc/Jhc/Tuples.hs 21
-
-
hunk ./lib/jhc/Jhc/Tuples.hs 45
-
-
-
hunk ./lib/jhc/Jhc/Tuples.hs 63
-
-
hunk ./lib/jhc/Jhc/Tuples.hs 87
-
hunk ./lib/jhc/jhc.yaml 61
+        - Jhc.Class.Num
+        - Jhc.Class.Ord
hunk ./src/FrontEnd/Class.hs 223
+-- Kind inference has already been done so we don't need to check for kind
+-- errors here.
hunk ./src/FrontEnd/Class.hs 227
-   | length classKind == length argTypeKind, and subsumptions
-        = return [emptyInstance { instSrcLoc = sloc, instDerived = False,
+    = return [emptyInstance { instSrcLoc = sloc, instDerived = False,
hunk ./src/FrontEnd/Class.hs 229
-   | otherwise = failSl sloc $ "hsInstDeclToInst: kind error, attempt to make\n" ++
-                      show convertedArgType ++ " (with kind " ++ show argTypeKind ++ ")\n" ++
-                      "an instance of class " ++ show className ++
-                      " (with kind " ++ show classKind ++ ") " ++ show subsumptions
hunk ./src/FrontEnd/Class.hs 230
-   (cntxt, (className, cargs@[convertedArgType])) = chToClassHead kt qType
-   classKind = kindOfClass className kt
-   argTypeKind = map getType cargs
-   subsumptions = zipWith isSubsumedBy classKind argTypeKind
+   (cntxt, (className, [convertedArgType])) = chToClassHead kt qType
hunk ./src/FrontEnd/Class.hs 232
+hsInstDeclToInst kt (HsDeclDeriving sloc qType)
+        = return [emptyInstance { instSrcLoc = sloc, instDerived = True,
+        instHead = cntxt :=> IsIn className convertedArgType }]
+   where
+   (cntxt, (className, cargs@[convertedArgType])) = chToClassHead kt qType
hunk ./src/FrontEnd/Class.hs 418
+-- We give all instance declarations the benefit of the doubt here, assuming
+-- they are correct. It is up to the typechecking pass to find any errors.
hunk ./src/FrontEnd/Class.hs 452
+    f decl@(HsDeclDeriving {}) = hsInstDeclToInst kt decl >>= \insts -> do
+        return $ foldl (flip addInstanceToHierarchy) mempty insts
hunk ./src/data/names.txt 96
-Eq              Jhc.Order.Eq
-Ord             Jhc.Order.Ord
+Eq              Jhc.Class.Ord.Eq
+Ord             Jhc.Class.Ord.Ord
hunk ./src/data/names.txt 105
-Num             Jhc.Num.Num
-Real            Jhc.Num.Real
-Integral	Jhc.Num.Integral
-Fractional	Jhc.Num.Fractional
+Num             Jhc.Class.Num.Num
+Real            Jhc.Class.Num.Real
+Integral	Jhc.Class.Num.Integral
+Fractional	Jhc.Class.Num.Fractional
hunk ./src/data/names.txt 134
-and              Jhc.Order.&&
+and              Jhc.Class.Ord.&&
hunk ./src/data/names.txt 141
-fromInteger          Jhc.Num.fromInteger
-fromInt              Jhc.Num.fromInt
-fromRational         Jhc.Num.fromRational
-negate               Jhc.Num.negate
-leq                  Jhc.Order.<=
-geq                  Jhc.Order.>=
-lt                   Jhc.Order.<
-gt                   Jhc.Order.>
-equals               Jhc.Order.==
+fromInteger          Jhc.Class.Num.fromInteger
+fromInt              Jhc.Class.Num.fromInt
+fromRational         Jhc.Class.Num.fromRational
+negate               Jhc.Class.Num.negate
+leq                  Jhc.Class.Ord.<=
+geq                  Jhc.Class.Ord.>=
+lt                   Jhc.Class.Ord.<
+gt                   Jhc.Class.Ord.>
+equals               Jhc.Class.Ord.==