[remove some TBox stuff, allow inst to substitute for mvars too
John Meacham <john@repetae.net>**20060210073618] hunk ./FrontEnd/Tc/Main.hs 356
-    ss <- sequence [newTVar Star | _ <- bs]
+    ss <- sequence [newMetaVar Tau Star | _ <- bs]
hunk ./FrontEnd/Tc/Main.hs 358
-    nenv <- sequence [ flattenType s >>= generalize >>= return . (,) n | (n,s) <- Map.toAscList $ mconcat $ snds rs]
-    liftIO $ mapM_ putStrLn $ sort [ show x ++ "  " ++ prettyPrintType y | (x,y) <- nenv]
-    addToCollectedEnv (Map.fromAscList nenv)
-    return (fsts rs, Map.fromAscList nenv)
+    let f n s = do
+            liftIO $ putStrLn $ "*** " ++ show n ++ " :: " ++ prettyPrintType s
+            s <- flattenType s
+            liftIO $ putStrLn $ "*** " ++ show n ++ " :: " ++ prettyPrintType s
+            s <- generalize s
+            liftIO $ putStrLn $ "*** " ++ show n ++ " :: " ++ prettyPrintType s
+            return (n,s)
+    nenv <- sequence [ f n s | (n,s) <- Map.toAscList $ mconcat $ snds rs]
+    addToCollectedEnv (Map.fromList nenv)
+    return (fsts rs, Map.fromList nenv)
hunk ./FrontEnd/Tc/Monad.hs 197
-    inst:: Map.Map Atom Type -> a -> a
+    inst:: Map.Map Int Type -> Map.Map Atom Type -> a -> a
hunk ./FrontEnd/Tc/Monad.hs 200
-    inst ts (TAp l r)     = TAp (inst ts l) (inst ts r)
-    inst ts (TArrow l r)  = TArrow (inst ts l) (inst ts r)
-    inst  _ t@TCon {}     = t
-    inst ts (TVar tv )
+    inst mm ts (TAp l r)     = TAp (inst mm ts l) (inst mm ts r)
+    inst mm ts (TArrow l r)  = TArrow (inst mm ts l) (inst mm ts r)
+    inst mm  _ t@TCon {}     = t
+    inst mm ts (TVar tv )
hunk ./FrontEnd/Tc/Monad.hs 207
-    inst ts (TForAll as qt) = TForAll as (inst (foldr Map.delete ts (map tyvarAtom as)) qt)
-    inst ts (TMetaVar mv) = TMetaVar mv
-    inst _ t = error $ "inst: " ++ show t
+    inst mm ts (TForAll as qt) = TForAll as (inst mm (foldr Map.delete ts (map tyvarAtom as)) qt)
+    inst mm ts (TMetaVar mv) | Just t <- Map.lookup (metaUniq mv) mm  = t
+    inst mm ts (TMetaVar mv) = TMetaVar mv
+    inst mm _ t = error $ "inst: " ++ show t
hunk ./FrontEnd/Tc/Monad.hs 214
-  inst ts = map (inst ts)
+  inst mm ts = map (inst mm ts)
hunk ./FrontEnd/Tc/Monad.hs 217
-  inst ts (ps :=> t) = inst ts ps :=> inst ts t
+  inst mm ts (ps :=> t) = inst mm ts ps :=> inst mm ts t
hunk ./FrontEnd/Tc/Monad.hs 220
-  inst ts (IsIn c t) = IsIn c (inst ts t)
+  inst mm ts (IsIn c t) = IsIn c (inst mm ts t)
hunk ./FrontEnd/Tc/Monad.hs 226
-    let (ps :=> t) = (inst (Map.fromList $ zip (map tyvarAtom as) ts) qt)
+    let (ps :=> t) = (inst mempty (Map.fromList $ zip (map tyvarAtom as) ts) qt)
hunk ./FrontEnd/Tc/Monad.hs 247
-    return (TForAll nvs $ inst (Map.fromList $ zip (map tyvarAtom vs) (map TVar nvs)) qt)
+    return (TForAll nvs $ inst mempty (Map.fromList $ zip (map tyvarAtom vs) (map TVar nvs)) qt)
hunk ./FrontEnd/Tc/Monad.hs 281
-    addPreds $ inst (Map.fromList [ (tyvarAtom bt,s) | (bt,s) <- vs ]) ps
+    addPreds $ inst mempty (Map.fromList [ (tyvarAtom bt,s) | (bt,s) <- vs ]) ps
hunk ./FrontEnd/Tc/Monad.hs 293
-    sequence_ [ varBind mv (TVar v) | v <- nvs |  mv <- vs ]
-    r <- flattenType (ps :=> r)
-    return $ TForAll nvs r
+    let mm =  Map.fromList  [ (metaUniq mv,(TVar v)) | v <- nvs |  mv <- vs ]
+        rr = inst mm mempty r
+        ps' = inst mm mempty ps
+    --r <- flattenType (ps :=> r)
+    return $ TForAll nvs (ps' :=> rr)
hunk ./FrontEnd/Tc/Type.hs 74
-isTau TBox {} = error "isTau: Box"
hunk ./FrontEnd/Tc/Type.hs 83
-isTau' TBox {} = error "isTau': Box"
hunk ./FrontEnd/Tc/Type.hs 88
-isBoxy TBox {} = error "isBoxy: Box"
hunk ./FrontEnd/Tc/Type.hs 162
-    f (TBox Star i _) = return $ atom $ text "_" <> tshow i
-    f t | ~(TBox k i _) <- t = return $ atom $ parens $ text "_" <> tshow i <> text " :: " <> pprint k
hunk ./FrontEnd/Tc/Type.hs 210
-            ft t@TBox { typeBox = box }
-                | openBoxes opt =  readIORef box >>= \x -> case x of
-                    Just x -> unVar' opt x
-                    Nothing -> error "unVar: empty box"
-                | otherwise = return t
hunk ./FrontEnd/Tc/Type.hs 259
-allFreeVars TBox {}       = []
hunk ./FrontEnd/Tc/Type.hs 266
-freeMetaVars TBox {}       = []