[generate TAssoc values from associated types when converting HsTypes to Types
John Meacham <john@repetae.net>**20061020045256] hunk ./FrontEnd/KindInfer.hs 502
--- note that the types are generated without generalised type
--- variables, ie there will be no TGens in the output
--- to get the generalised variables a second phase
--- of generalisation must be applied
+fromTyApp t = f t [] where
+    f (HsTyApp a b) rs = f a (b:rs)
+    f t rs = (t,rs)
hunk ./FrontEnd/KindInfer.hs 507
+aHsTypeToType kt@(KindEnv _ at) t | (HsTyCon con,xs) <- fromTyApp t, let nn = toName TypeConstructor con, Just (n1,n2) <- Map.lookup nn at =
+    TAssoc {
+        typeCon = Tycon nn (kindOf nn kt),
+        typeClassArgs = map (aHsTypeToType kt) (take n1 xs),
+        typeExtraArgs = map (aHsTypeToType kt) (take n2 $ drop n1 xs)
+    }
hunk ./FrontEnd/KindInfer.hs 576
+    f t@TAssoc {} = t { typeClassArgs = map f (typeClassArgs t), typeExtraArgs = map f (typeExtraArgs t) }
hunk ./FrontEnd/Tc/Monad.hs 95
-    tcInstanceEnv   :: InstanceEnv,
+    tcInstanceEnv       :: InstanceEnv,
hunk ./FrontEnd/Tc/Monad.hs 268
+    inst mm ts (TAssoc tc as bs) = TAssoc tc (map (inst mm ts) as) (map (inst mm ts) bs)
hunk ./FrontEnd/Tc/Monad.hs 381
-    ft (TAp x y) = liftM2 TAp (ft' x) (ft' y)
-    ft (TArrow x y) = liftM2 TArrow (ft' x) (ft' y)
-    ft t@TCon {} = return t
hunk ./FrontEnd/Tc/Monad.hs 396
-    ft t | ~(Just tv) <- extractTyVar t  = return (TVar tv)
+    ft t = tickleM ft' t
hunk ./FrontEnd/Tc/Type.hs 230
-    tickleM f (TForAll ta (ps :=> t)) = return (TForAll ta . (ps :=>)) `ap` f t
-    tickleM f (TExists ta (ps :=> t)) = return (TExists ta . (ps :=>)) `ap` f t
+    tickleM f (TForAll ta (ps :=> t)) = do
+        ps <- mapM (tickleM f) ps
+        return (TForAll ta . (ps :=>)) `ap` f t
+    tickleM f (TExists ta (ps :=> t)) = do
+        ps <- mapM (tickleM f) ps
+        return (TExists ta . (ps :=>)) `ap` f t