[switch CanType to use an associated type instead of a FD
John Meacham <john@repetae.net>**20120122130258
 Ignore-this: f9ec335e764269885242f2d46df93944
] hunk ./src/E/Eta.hs 25
+import E.TypeCheck
hunk ./src/E/TypeCheck.hs 5
+    infertype,
+    typecheck,
hunk ./src/E/TypeCheck.hs 187
-instance CanType E E where
+instance CanType E where
+    type TypeOf E = E
hunk ./src/E/TypeCheck.hs 214
-instance CanType ESort ESort where
+instance CanType ESort where
+    type TypeOf ESort = ESort
hunk ./src/E/TypeCheck.hs 220
-instance CanType TVr E where
+instance CanType TVr where
+    type TypeOf TVr = E
hunk ./src/E/TypeCheck.hs 223
-instance CanType (Lit x t) t where
+instance CanType (Lit x t) where
+    type TypeOf (Lit x t) = t
hunk ./src/E/TypeCheck.hs 226
-instance CanType e t => CanType (Alt e) t where
+instance CanType e => CanType (Alt e) where
+    type TypeOf (Alt e) = TypeOf e
hunk ./src/E/TypeCheck.hs 379
-instance CanTypeCheck DataTable E E where
+-- This should perform a full typecheck and may take any extra information needed as an extra parameter
+class CanTypeCheck a where
+    typecheck :: Monad m => DataTable -> a -> m E
+
+infertype :: CanTypeCheck a => DataTable -> a -> E
+infertype env a = case typecheck env a of
+    Left s -> error $ "infertype: " ++ s
+    Right x -> x
+
+instance CanTypeCheck E where
hunk ./src/E/TypeCheck.hs 393
-instance CanTypeCheck DataTable TVr E where
+instance CanTypeCheck TVr where
hunk ./src/E/TypeCheck.hs 398
-instance CanTypeCheck DataTable (Lit a E) E where
+instance CanTypeCheck (Lit a E) where
hunk ./src/E/TypeCheck.hs 403
-instance CanTypeCheck DataTable (Alt E) E where
+instance CanTypeCheck (Alt E) where
hunk ./src/E/TypeCheck.hs 406
-instance CanTypeCheck DataTable [(TVr,E)] [E] where
-    typecheck dataTable ds = do mapM (typecheck dataTable) (snds ds)
-
hunk ./src/E/WorkerWrapper.hs 11
-import E.TypeCheck()
+import E.TypeCheck
hunk ./src/FrontEnd/Representation.hs 1
-{-
-        Copyright:        Mark Jones and The Hatchet Team
-                          (see file Contributors)
-        Module:           Representation
-        Primary Authors:  Mark Jones and Bernie Pope
-        Description:      The basic data types for representing objects
-                          in the type inference algorithm.
-        Notes:            See the file License for license information
-                          Large parts of this module were derived from
-                          the work of Mark Jones' "Typing Haskell in
-                          Haskell", (http://www.cse.ogi.edu/~mpj/thih/)
--}
-
hunk ./src/FrontEnd/Representation.hs 25
-
hunk ./src/FrontEnd/Representation.hs 31
+import FrontEnd.Tc.Kind
hunk ./src/FrontEnd/Representation.hs 34
-import Support.CanType
hunk ./src/FrontEnd/Representation.hs 35
+import Support.CanType
hunk ./src/FrontEnd/Representation.hs 38
-import FrontEnd.Tc.Kind
-
-
---------------------------------------------------------------------------------
hunk ./src/FrontEnd/Representation.hs 151
-
hunk ./src/FrontEnd/Representation.hs 195
-
hunk ./src/FrontEnd/Representation.hs 198
-
hunk ./src/FrontEnd/Representation.hs 258
-
hunk ./src/FrontEnd/Representation.hs 264
-
-
hunk ./src/FrontEnd/Representation.hs 287
-
-instance CanType MetaVar Kind where
+instance CanType MetaVar where
+    type TypeOf MetaVar = Kind
hunk ./src/FrontEnd/Representation.hs 291
-instance CanType Tycon Kind where
+instance CanType Tycon where
+    type TypeOf Tycon = Kind
hunk ./src/FrontEnd/Representation.hs 295
-instance CanType Tyvar Kind where
+instance CanType Tyvar where
+    type TypeOf Tyvar = Kind
hunk ./src/FrontEnd/Representation.hs 299
-instance CanType Type Kind where
-  getType (TCon tc) = getType tc
-  getType (TVar u)  = getType u
-  getType typ@(TAp t _) = case (getType t) of
-                     (Kfun _ k) -> k
-                     x -> error $ "Representation.getType: kind error in: " ++ (show typ)
-  getType (TArrow _l _r) = kindStar
-  getType (TForAll _ (_ :=> t)) = getType t
-  getType (TExists _ (_ :=> t)) = getType t
-  getType (TMetaVar mv) = getType mv
-  getType ta@TAssoc {} = getType (tassocToAp ta)
+instance CanType Type where
+    type TypeOf Type = Kind
+    getType (TCon tc) = getType tc
+    getType (TVar u)  = getType u
+    getType typ@(TAp t _) = case (getType t) of
+                       (Kfun _ k) -> k
+                       x -> error $ "Representation.getType: kind error in: " ++ (show typ)
+    getType (TArrow _l _r) = kindStar
+    getType (TForAll _ (_ :=> t)) = getType t
+    getType (TExists _ (_ :=> t)) = getType t
+    getType (TMetaVar mv) = getType mv
+    getType ta@TAssoc {} = getType (tassocToAp ta)
hunk ./src/Grin/Grin.hs 444
-instance CanType Exp [Ty] where
+instance CanType Exp where
+    type TypeOf Exp = [Ty]
hunk ./src/Grin/Grin.hs 476
-instance CanType Val Ty where
+instance CanType Val where
+    type TypeOf Val = Ty
hunk ./src/Grin/SSimplify.hs 298
-instance CanType UnboxingResult [Ty] where
+instance CanType UnboxingResult where
+    type TypeOf UnboxingResult = [Ty]
hunk ./src/Grin/SSimplify.hs 306
-instance CanType Unbox Ty where
+instance CanType Unbox where
+    type TypeOf Unbox = Ty
hunk ./src/Support/CanType.hs 6
-class CanType a e | a -> e where
-    getType :: a -> e
+class CanType a where
+    type TypeOf a
+    getType :: a -> (TypeOf a)
hunk ./src/Support/CanType.hs 10
-instance CanType e t => CanType [e] [t] where
+instance CanType e => CanType [e] where
+    type TypeOf [e] = [TypeOf e]
hunk ./src/Support/CanType.hs 14
--- This should perform a full typecheck and may take any extra information needed as an extra parameter
-class CanTypeCheck env a ty | a -> ty env where
-    typecheck :: Monad m => env -> a -> m ty
+instance CanType e => CanType (Maybe e) where
+    type TypeOf (Maybe e) = Maybe (TypeOf e)
+    getType Nothing = Nothing
+    getType (Just x) = Just (getType x)
hunk ./src/Support/CanType.hs 19
-infertype :: CanTypeCheck env a ty => env -> a -> ty
-infertype env a = case typecheck env a of
-    Left s -> error $ "infertype: " ++ s
-    Right x -> x
+instance (CanType e1, CanType e2) => CanType (Either e1 e2) where
+    type TypeOf (Either e1 e2) = Either (TypeOf e1) (TypeOf e2)
+    getType (Left x) = Left $ getType x
+    getType (Right x) = Right $ getType x