[annotate types with their newtype expansion, check expansion are valid in typechecker.
John Meacham <john@repetae.net>**20061013000748] hunk ./DataConstructors.hs 10
+    removeNewtypes,
hunk ./DataConstructors.hs 23
+    updateLit,
hunk ./DataConstructors.hs 45
+import E.Traverse
hunk ./DataConstructors.hs 392
+
+updateLit :: DataTable -> Lit e t -> Lit e t
+updateLit _ l@LitInt {} = l
+updateLit dataTable lc@LitCons { litName = n } =  lc { litAliasFor = af } where
+    af = do
+        Constructor { conChildren = Just [x], conSlots = cs } <- getConstructor n dataTable
+        Constructor { conAlias = ErasedAlias, conSlots = [sl] } <- getConstructor x dataTable
+        return (foldr ELam sl [ tVr i s | s <- cs | i <- [2,4..]])
+
+removeNewtypes :: DataTable -> E -> E
+removeNewtypes dataTable e = runIdentity (f e) where
+    f ec@ECase {} = emapEGH f f return ec { eCaseAlts = map g (eCaseAlts ec) } where
+        g (Alt l e) = Alt (updateLit dataTable l) e
+    f (ELit l) = emapEGH f f return (ELit (updateLit dataTable l))
+    f e = emapEGH f f return e
+
+
hunk ./DataConstructors.hs 410
-toDataTable :: (Map.Map Name Kind) -> (Map.Map Name Type) -> [HsDecl] -> DataTable
-toDataTable km cm ds = DataTable (Map.mapWithKey fixupMap $ Map.fromList [ (conName x,x) | x <- ds' ])  where
+toDataTable :: (Map.Map Name Kind) -> (Map.Map Name Type) -> [HsDecl] -> DataTable -> DataTable
+toDataTable km cm ds currentDataTable = newDataTable  where
+    newDataTable = DataTable (Map.mapWithKey fixupMap $ Map.fromList [ (conName x,procNewTypes x) | x <- ds' ])
+    procNewTypes c = c { conExpr = f (conExpr c), conType = f (conType c), conSlots = map f (conSlots c) } where
+        f = removeNewtypes (newDataTable `mappend` currentDataTable)
hunk ./DataConstructors.hs-boot 11
+updateLit :: DataTable -> Lit e t -> Lit e t
hunk ./E/FromHs.hs 798
-deNewtype dataTable e = f e where
+deNewtype dataTable e = removeNewtypes dataTable (f e) where
hunk ./E/TypeAnalysis.hs 258
-        return $ ELit (litCons { litName = h, litArgs = as', litType = kind })
+        return $ ELit (updateLit dataTable litCons { litName = h, litArgs = as', litType = kind })
hunk ./E/TypeAnalysis.hs 341
-        valToPat' (ELit LitCons { litName = x, litArgs = ts, litType = t }) = LitCons { litName = x, litArgs = [ z | ~(EVar z) <- ts ], litType = t }
+        valToPat' (ELit LitCons { litName = x, litArgs = ts, litType = t, litAliasFor = af }) = LitCons { litName = x, litArgs = [ z | ~(EVar z) <- ts ], litType = t, litAliasFor = af }
hunk ./E/TypeCheck.hs 6
-    removeNewtypes,
hunk ./E/TypeCheck.hs 80
-typ e@(EAp (ELit LitCons { litType = ty }) b) | ty == eStar = eStar -- XXX functions might have unboxed return types in the future
+-- typ e@(EAp (ELit LitCons { litType = ty }) b) | ty == eStar = eStar -- XXX functions might have unboxed return types in the future
+typ (EAp (ELit lc@LitCons { litAliasFor = Just af }) b) = getType (foldl EAp af (litArgs lc ++ [b]))
hunk ./E/TypeCheck.hs 137
-removeNewtypes :: DataTable -> E -> E
-removeNewtypes dataTable e = runIdentity (f e) where
-    f e = emapEGH f f' return e
-    f' (EAp a b) = do
-        a' <- f' a
-        b' <- f' b
-        return (eAp a' b')
-    f' el@ELit {} = emapEGH f' return return (followAliases dataTable el)
-    f' t = emapEGH f' return return t
hunk ./E/TypeCheck.hs 151
+    fc (ELit lc@LitCons {}) | let lc' = updateLit dataTable lc, litAliasFor lc /= litAliasFor lc' = fail $ "Alias not correct: " ++ show (lc, litAliasFor lc')
hunk ./Main.hs 169
+{-
hunk ./Main.hs 181
+-}
hunk ./Main.hs 253
-    let dataTable = toDataTable (getConstructorKinds (hoKinds ho')) (tiAllAssumptions tiData) originalDecls
+    let dataTable = toDataTable (getConstructorKinds (hoKinds ho')) (tiAllAssumptions tiData) originalDecls (hoDataTable ho)
hunk ./Main.hs 304
-    prog <- denewtypeProgram prog
+--    prog <- denewtypeProgram prog
hunk ./Main.hs 647
-    prog <- denewtypeProgram prog
+--    prog <- denewtypeProgram prog
hunk ./Main.hs 667
-    prog <- denewtypeProgram prog
+--    prog <- denewtypeProgram prog
hunk ./Main.hs 701
-    prog <- denewtypeProgram prog
+--    prog <- denewtypeProgram prog