X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcArrows.lhs;h=ae4a1e876125158fdc0d92e17e46b935503ed3ff;hb=1cf00bfef1c35b89c21d1eaa9f6be7354a40f016;hp=227c6ce923abded27256a736230495ac740d7553;hpb=b10d7d079ec9c3fc22d4700fe484dd297bddb805;p=ghc-hetmet.git diff --git a/compiler/typecheck/TcArrows.lhs b/compiler/typecheck/TcArrows.lhs index 227c6ce..ae4a1e8 100644 --- a/compiler/typecheck/TcArrows.lhs +++ b/compiler/typecheck/TcArrows.lhs @@ -7,7 +7,7 @@ Typecheck arrow notation \begin{code} module TcArrows ( tcProc ) where -import {-# SOURCE #-} TcExpr( tcMonoExpr, tcInferRho ) +import {-# SOURCE #-} TcExpr( tcMonoExpr, tcInferRho, tcSyntaxOp ) import HsSyn import TcMatches @@ -125,11 +125,17 @@ tc_cmd env in_cmd@(HsCase scrut matches) (stk, res_ty) mc_body = mc_body } mc_body body res_ty' = tcGuardedCmd env body stk res_ty' -tc_cmd env (HsIf pred b1 b2) res_ty - = do { pred' <- tcMonoExpr pred boolTy - ; b1' <- tcCmd env b1 res_ty - ; b2' <- tcCmd env b2 res_ty - ; return (HsIf pred' b1' b2') +tc_cmd env (HsIf mb_fun pred b1 b2) (stack_ty,res_ty) + = do { pred_ty <- newFlexiTyVarTy openTypeKind + ; b_ty <- newFlexiTyVarTy openTypeKind + ; let if_ty = mkFunTys [pred_ty, b_ty, b_ty] res_ty + ; mb_fun' <- case mb_fun of + Nothing -> return Nothing + Just fun -> liftM Just (tcSyntaxOp IfOrigin fun if_ty) + ; pred' <- tcMonoExpr pred pred_ty + ; b1' <- tcCmd env b1 (stack_ty,b_ty) + ; b2' <- tcCmd env b2 (stack_ty,b_ty) + ; return (HsIf mb_fun' pred' b1' b2') } ------------------------------------------- @@ -231,7 +237,7 @@ tc_cmd env cmd@(HsDo do_or_lc stmts body _ty) (cmd_stk, res_ty) tc_cmd env cmd@(HsArrForm expr fixity cmd_args) (cmd_stk, res_ty) = addErrCtxt (cmdCtxt cmd) $ do { cmds_w_tys <- zipWithM new_cmd_ty cmd_args [1..] - ; [w_tv] <- tcInstSkolTyVars ArrowSkol [alphaTyVar] + ; [w_tv] <- tcInstSkolTyVars [alphaTyVar] ; let w_ty = mkTyVarTy w_tv -- Just a convenient starting point -- a ((w,t1) .. tn) t