[modify type checker to not aggresively expand newtypes and understand the litAliasFor field
John Meacham <john@repetae.net>**20061013005857] hunk ./E/Demand.hs 319
-analyze ec@ECase { eCaseBind = b, eCaseAlts = [Alt lc@LitCons { litName = h, litArgs = ts, litType = _ } alt], eCaseDefault = Nothing } s = do
+analyze ec@ECase { eCaseBind = b, eCaseAlts = [Alt lc@LitCons { litName = h, litArgs = ts } alt], eCaseDefault = Nothing } s = do
hunk ./E/E.hs 172
-litHead LitCons { litName = s } = litCons { litName = s, litType = () }
+litHead LitCons { litName = s, litAliasFor = af } = litCons { litName = s, litType = (), litAliasFor = af }
hunk ./E/Eval.hs 26
-    eval' (ELit lc@LitCons { litName = n, litArgs = es, litType = t }) [] = ELit lc { litArgs = map eval es }
+    eval' (ELit lc@LitCons { litArgs = es }) [] = ELit lc { litArgs = map eval es }
hunk ./E/Eval.hs 31
+    eval' (ELit LitCons { litArgs = es, litAliasFor = Just af }) (t:rest) = eval' af (es ++ t:rest)
hunk ./E/Eval.hs 80
+    eval' ds (ELit LitCons { litArgs = es, litAliasFor = Just af }) (t:rest) = eval' ds af (es ++ t:rest)
hunk ./E/Inline.hs 68
+app' (ELit LitCons { litName = n, litArgs = es, litAliasFor = Just af }) bs@(_:_) = do
+    mtick (toAtom $ "E.Simplify.newtype-reduce.{" ++ show n ++ "}" )
+    app (foldl eAp af (es ++ bs),[])
hunk ./E/SSimplify.hs 775
+    app' (ELit LitCons { litName = n, litArgs = es, litAliasFor = Just af }) bs@(_:_) = do
+        mtick (toAtom $ "E.Simplify.newtype-reduce.{" ++ show n ++ "}" )
+        app' (foldl eAp af (es ++ bs)) []
hunk ./E/Subst.hs 165
-eAp (EPi (TVr { tvrIdent =  0 }) b) _ = b
-eAp (EPi t b) e = subst t e b
-eAp (ELam t b) e = subst t e b
+eAp (EPi t b) e = if tvrIdent t == 0 then b else subst t e b
+eAp (ELam t b) e = if tvrIdent t == 0 then b else subst t e b
hunk ./E/TypeCheck.hs 125
-simplifyAp :: Monad m => DataTable -> E -> E -> m E
-simplifyAp dataTable (EAp a b) c = do
-    na <- simplifyAp dataTable a b
-    simplifyAp dataTable na c
-simplifyAp _ (ELit lc@LitCons { litArgs = xs, litType = EPi tvr r }) b = do
-        return (ELit lc { litArgs = (xs ++ [b]), litType = subst tvr b r })
-simplifyAp dataTable a@ELit {} b = case followAliases dataTable a  of
-        ELit {} -> fail $ "simplifyAp: " ++ render (tupled [ePretty a, ePretty b])
-        (EPi tvr e) -> do
-                return (subst tvr b e)
-simplifyAp _ a b = fail $ "simplifyAp: " ++ render (tupled [ePretty a, ePretty b])
-
-
hunk ./E/TypeCheck.hs 135
-    rfc e =  withContextDoc (text "fullCheck:" </> prettyE e) (fc (followAliases dataTable e) >>=  strong')
-    rfc' nds e = withContextDoc (text "fullCheck:" </> prettyE e) (inferType' nds (followAliases dataTable e) >>=  strong')
-    strong' e = withContextDoc (text "Strong:" </> prettyE e) $ strong ds (followAliases dataTable e)
+    rfc e =  withContextDoc (text "fullCheck:" </> prettyE e) (fc e >>=  strong')
+    rfc' nds e = withContextDoc (text "fullCheck:" </> prettyE e) (inferType' nds e >>=  strong')
+    strong' e = withContextDoc (text "Strong:" </> prettyE e) $ strong ds e
hunk ./E/TypeCheck.hs 162
+    fc (EAp (ELit lc@LitCons { litAliasFor = Just af }) b) = fc (EAp (foldl eAp af (litArgs lc)) b)
hunk ./E/TypeCheck.hs 167
-            strong' $ eAp (followAliases dataTable a') b
+            strong' $ eAp a' b
hunk ./E/TypeCheck.hs 310
-    rfc e =  withContextDoc (text "fullCheck':" </> prettyE e) (fc (followAliases dataTable e) >>=  strong')
-    rfc' nds e =  withContextDoc (text "fullCheck':" </> prettyE e) (inferType' nds  (followAliases dataTable e) >>=  strong')
-    strong' e = withContextDoc (text "Strong':" </> prettyE e) $ strong ds (followAliases dataTable e)
+    rfc e =  withContextDoc (text "fullCheck':" </> prettyE e) (fc e >>=  strong')
+    rfc' nds e =  withContextDoc (text "fullCheck':" </> prettyE e) (inferType' nds  e >>=  strong')
+    strong' e = withContextDoc (text "Strong':" </> prettyE e) $ strong ds e
hunk ./E/TypeCheck.hs 326
+    fc (EAp (ELit lc@LitCons { litAliasFor = Just af }) b) = fc (EAp (foldl eAp af (litArgs lc)) b)
hunk ./E/TypeCheck.hs 329
-        strong' (eAp (followAliases dataTable a') b)
+        strong' (eAp a' b)