[project @ 2002-06-05 14:39:27 by simonpj]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcHsSyn.lhs
index 2d01c49..3fda515 100644 (file)
@@ -11,7 +11,7 @@ module TcHsSyn (
        TcMonoBinds, TcHsBinds, TcPat,
        TcExpr, TcGRHSs, TcGRHS, TcMatch,
        TcStmt, TcArithSeqInfo, TcRecordBinds,
-       TcHsModule, TcCoreExpr, TcDictBinds,
+       TcHsModule, TcDictBinds,
        TcForeignExportDecl,
        
        TypecheckedHsBinds, TypecheckedRuleDecl,
@@ -21,7 +21,7 @@ module TcHsSyn (
        TypecheckedMatch, TypecheckedHsModule,
        TypecheckedGRHSs, TypecheckedGRHS,
        TypecheckedRecordBinds, TypecheckedDictBinds,
-       TypecheckedMatchContext,
+       TypecheckedMatchContext, TypecheckedCoreBind,
 
        mkHsTyApp, mkHsDictApp, mkHsConApp,
        mkHsTyLam, mkHsDictLam, mkHsLet,
@@ -55,7 +55,7 @@ import TysPrim          ( charPrimTy, intPrimTy, floatPrimTy,
                  )
 import TysWiredIn ( charTy, stringTy, intTy, integerTy,
                    mkListTy, mkPArrTy, mkTupleTy, unitTy )
-import CoreSyn    ( Expr )
+import CoreSyn    ( Expr(..), CoreExpr, CoreBind, Bind(..), CoreAlt, Note(..) )
 import Var       ( isId )
 import BasicTypes ( RecFlag(..), Boxity(..), IPName(..), ipNameName )
 import Bag
@@ -88,7 +88,6 @@ type TcArithSeqInfo   = ArithSeqInfo TcId TcPat
 type TcRecordBinds     = HsRecordBinds TcId TcPat
 type TcHsModule        = HsModule TcId TcPat
 
-type TcCoreExpr        = Expr TcId
 type TcForeignExportDecl = ForeignDecl TcId
 type TcRuleDecl         = RuleDecl    TcId TcPat
 
@@ -107,6 +106,7 @@ type TypecheckedRecordBinds = HsRecordBinds Id TypecheckedPat
 type TypecheckedHsModule       = HsModule      Id TypecheckedPat
 type TypecheckedForeignDecl     = ForeignDecl Id
 type TypecheckedRuleDecl       = RuleDecl      Id TypecheckedPat
+type TypecheckedCoreBind        = (Id, CoreExpr)
 \end{code}
 
 \begin{code}
@@ -470,11 +470,11 @@ zonkExpr (HsLet binds expr)
     zonkExpr expr      `thenNF_Tc` \ new_expr ->
     returnNF_Tc (HsLet new_binds new_expr)
 
-zonkExpr (HsWith expr binds)
+zonkExpr (HsWith expr binds is_with)
   = zonkIPBinds binds                          `thenNF_Tc` \ new_binds ->
     tcExtendGlobalValEnv (map (ipNameName . fst) new_binds)    $
     zonkExpr expr                              `thenNF_Tc` \ new_expr ->
-    returnNF_Tc (HsWith new_expr new_binds)
+    returnNF_Tc (HsWith new_expr new_binds is_with)
     where
        zonkIPBinds = mapNF_Tc zonkIPBind
        zonkIPBind (n, e)
@@ -482,16 +482,11 @@ zonkExpr (HsWith expr binds)
              zonkExpr e                `thenNF_Tc` \ e' ->
              returnNF_Tc (n', e')
 
-zonkExpr (HsDo _ _ _) = panic "zonkExpr:HsDo"
-
-zonkExpr (HsDoOut do_or_lc stmts return_id then_id zero_id ty src_loc)
+zonkExpr (HsDo do_or_lc stmts ids ty src_loc)
   = zonkStmts stmts            `thenNF_Tc` \ new_stmts ->
-    zonkTcTypeToType ty        `thenNF_Tc` \ new_ty   ->
-    zonkIdOcc return_id                `thenNF_Tc` \ new_return_id ->
-    zonkIdOcc then_id          `thenNF_Tc` \ new_then_id ->
-    zonkIdOcc zero_id          `thenNF_Tc` \ new_zero_id ->
-    returnNF_Tc (HsDoOut do_or_lc new_stmts new_return_id new_then_id new_zero_id
-                        new_ty src_loc)
+    zonkTcTypeToType ty                `thenNF_Tc` \ new_ty   ->
+    mapNF_Tc zonkIdOcc ids     `thenNF_Tc` \ new_ids ->
+    returnNF_Tc (HsDo do_or_lc new_stmts new_ids new_ty src_loc)
 
 zonkExpr (ExplicitList ty exprs)
   = zonkTcTypeToType ty                `thenNF_Tc` \ new_ty ->
@@ -514,13 +509,12 @@ zonkExpr (RecordConOut data_con con_expr rbinds)
 
 zonkExpr (RecordUpd _ _) = panic "zonkExpr:RecordUpd"
 
-zonkExpr (RecordUpdOut expr in_ty out_ty dicts rbinds)
+zonkExpr (RecordUpdOut expr in_ty out_ty rbinds)
   = zonkExpr expr              `thenNF_Tc` \ new_expr ->
     zonkTcTypeToType in_ty     `thenNF_Tc` \ new_in_ty ->
     zonkTcTypeToType out_ty    `thenNF_Tc` \ new_out_ty ->
-    mapNF_Tc zonkIdOcc dicts   `thenNF_Tc` \ new_dicts ->
     zonkRbinds rbinds  `thenNF_Tc` \ new_rbinds ->
-    returnNF_Tc (RecordUpdOut new_expr new_in_ty new_out_ty new_dicts new_rbinds)
+    returnNF_Tc (RecordUpdOut new_expr new_in_ty new_out_ty new_rbinds)
 
 zonkExpr (ExprWithTySig _ _) = panic "zonkExpr:ExprWithTySig"
 zonkExpr (ArithSeqIn _)      = panic "zonkExpr:ArithSeqIn"
@@ -715,7 +709,7 @@ zonkPat (RecPat n ty tvs dicts rpats)
        returnNF_Tc ((f, new_pat, pun), ids)
 
 zonkPat (LitPat lit ty)
-  = zonkTcTypeToType ty            `thenNF_Tc` \ new_ty  ->
+  = zonkTcTypeToType ty                `thenNF_Tc` \ new_ty  ->
     returnNF_Tc (LitPat lit new_ty, emptyBag)
 
 zonkPat (SigPat pat ty expr)
@@ -730,15 +724,15 @@ zonkPat (NPat lit ty expr)
     returnNF_Tc (NPat lit new_ty new_expr, emptyBag)
 
 zonkPat (NPlusKPat n k ty e1 e2)
-  = zonkIdBndr n               `thenNF_Tc` \ new_n ->
-    zonkTcTypeToType ty        `thenNF_Tc` \ new_ty ->
-    zonkExpr e1                `thenNF_Tc` \ new_e1 ->
-    zonkExpr e2                `thenNF_Tc` \ new_e2 ->
+  = zonkIdBndr n               `thenNF_Tc` \ new_n ->
+    zonkTcTypeToType ty                `thenNF_Tc` \ new_ty ->
+    zonkExpr e1                        `thenNF_Tc` \ new_e1 ->
+    zonkExpr e2                        `thenNF_Tc` \ new_e2 ->
     returnNF_Tc (NPlusKPat new_n k new_ty new_e1 new_e2, unitBag new_n)
 
 zonkPat (DictPat ds ms)
-  = mapNF_Tc zonkIdBndr ds    `thenNF_Tc` \ new_ds ->
-    mapNF_Tc zonkIdBndr ms    `thenNF_Tc` \ new_ms ->
+  = mapNF_Tc zonkIdBndr ds      `thenNF_Tc` \ new_ds ->
+    mapNF_Tc zonkIdBndr ms      `thenNF_Tc` \ new_ms ->
     returnNF_Tc (DictPat new_ds new_ms,
                 listToBag new_ds `unionBags` listToBag new_ms)
 
@@ -791,3 +785,4 @@ zonkRule (IfaceRuleOut fun rule)
   = zonkIdOcc fun      `thenNF_Tc` \ fun' ->
     returnNF_Tc (IfaceRuleOut fun' rule)
 \end{code}
+