De-polymorphise
[ghc-hetmet.git] / compiler / typecheck / TcArrows.lhs
index 4593482..2e59926 100644 (file)
@@ -27,7 +27,6 @@ import Name
 import TysWiredIn
 import VarSet 
 import TysPrim
-import Type
 
 import SrcLoc
 import Outputable
@@ -53,7 +52,7 @@ tcProc pat cmd exp_ty
     do { ((exp_ty1, res_ty), coi) <- boxySplitAppTy exp_ty 
        ; ((arr_ty, arg_ty), coi1) <- boxySplitAppTy exp_ty1
        ; let cmd_env = CmdEnv { cmd_arr = arr_ty }
-       ; (pat', cmd') <- tcProcPat pat arg_ty res_ty $
+       ; (pat', cmd') <- tcPat ProcExpr pat arg_ty res_ty $
                          tcCmdTop cmd_env cmd []
         ; let res_coi = mkTransCoI coi (mkAppTyCoI exp_ty1 coi1 res_ty IdCo)
        ; return (pat', cmd', res_coi) 
@@ -186,8 +185,8 @@ tc_cmd env cmd@(HsLam (MatchGroup [L mtch_loc (match@(Match pats _maybe_rhs_sig
                  (kappaUnderflow cmd)
 
                -- Check the patterns, and the GRHSs inside
-       ; (pats', grhss') <- setSrcSpan mtch_loc                $
-                            tcLamPats pats cmd_stk res_ty      $
+       ; (pats', grhss') <- setSrcSpan mtch_loc                        $
+                            tcPats LambdaExpr pats cmd_stk res_ty      $
                             tc_grhss grhss
 
        ; let match' = L mtch_loc (Match pats' Nothing grhss')
@@ -215,11 +214,10 @@ tc_cmd env cmd@(HsLam (MatchGroup [L mtch_loc (match@(Match pats _maybe_rhs_sig
 
 tc_cmd env cmd@(HsDo do_or_lc stmts body _ty) (cmd_stk, res_ty)
   = do         { checkTc (null cmd_stk) (nonEmptyCmdStkErr cmd)
-       ; (stmts', body') <- tcStmts do_or_lc tc_stmt stmts res_ty $
+       ; (stmts', body') <- tcStmts do_or_lc (tcMDoStmt tc_rhs) stmts res_ty $
                             tcGuardedCmd env body []
        ; return (HsDo do_or_lc stmts' body' res_ty) }
   where
-    tc_stmt = tcMDoStmt tc_rhs
     tc_rhs rhs = do { ty <- newFlexiTyVarTy liftedTypeKind
                    ; rhs' <- tcCmd env rhs ([], ty)
                    ; return (rhs', ty) }
@@ -295,14 +293,13 @@ tc_cmd env cmd@(HsArrForm expr fixity cmd_args) (cmd_stk, res_ty)
 
     unscramble :: TcType -> (TcType, [TcType])
     -- unscramble ((w,s1) .. sn)       =  (w, [s1..sn])
-    unscramble ty
+    unscramble ty = unscramble' ty []
+
+    unscramble' ty ss
        = case tcSplitTyConApp_maybe ty of
            Just (tc, [t,s]) | tc == pairTyCon 
-              ->  let 
-                     (w,ss) = unscramble t  
-                  in (w, s:ss)
-                                   
-           _ -> (ty, [])
+              ->  unscramble' t (s:ss)
+           _ -> (ty, ss)
 
 -----------------------------------------------------------------
 --             Base case for illegal commands