import TysWiredIn
import VarSet
import TysPrim
-import Type
import SrcLoc
import Outputable
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) }
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