[project @ 2003-10-09 11:58:39 by simonpj]
[ghc-hetmet.git] / ghc / compiler / deSugar / DsGRHSs.lhs
index 57ef74f..75c76d6 100644 (file)
@@ -18,8 +18,10 @@ import Type          ( Type )
 
 import DsMonad
 import DsUtils
+import Unique          ( Uniquable(..) )
 import PrelInfo                ( nON_EXHAUSTIVE_GUARDS_ERROR_ID )
-import PrelNames       ( otherwiseIdKey, trueDataConKey, hasKey )
+import TysWiredIn      ( trueDataConId )
+import PrelNames       ( otherwiseIdKey, hasKey )
 \end{code}
 
 @dsGuarded@ is used for both @case@ expressions and pattern bindings.
@@ -49,8 +51,8 @@ dsGRHSs :: TypecheckedMatchContext -> [TypecheckedPat]        -- These are to build a M
        -> TypecheckedGRHSs                             -- Guarded RHSs
        -> DsM (Type, MatchResult)
 
-dsGRHSs kind pats (GRHSs grhss binds (Just ty))
-  = mapDs (dsGRHS kind pats) grhss             `thenDs` \ match_results ->
+dsGRHSs kind pats (GRHSs grhss binds ty)
+  = mappM (dsGRHS kind pats) grhss             `thenDs` \ match_results ->
     let 
        match_result1 = foldr1 combineMatchResults match_results
        match_result2 = adjustMatchResultDs (dsLet binds) match_result1
@@ -74,7 +76,7 @@ matchGuard :: [TypecheckedStmt]       -- Guard
            -> DsMatchContext            -- Context
           -> DsM MatchResult
 
--- See comments with HsExpr.HsStmt re what an ExprStmt means
+-- See comments with HsExpr.Stmt re what an ExprStmt means
 -- Here we must be in a guard context (not do-expression, nor list-comp)       
 
 matchGuard [ResultStmt expr locn] ctx 
@@ -83,12 +85,14 @@ matchGuard [ResultStmt expr locn] ctx
 
        -- ExprStmts must be guards
        -- Turn an "otherwise" guard is a no-op
-matchGuard (ExprStmt (HsVar v) _ : stmts) ctx
+matchGuard (ExprStmt (HsVar v) _ _ : stmts) ctx
   |  v `hasKey` otherwiseIdKey
-  || v `hasKey` trueDataConKey
+  || v `hasKey` getUnique trueDataConId        
+       -- trueDataConId doesn't have the same 
+       -- unique as trueDataCon
   = matchGuard stmts ctx
 
-matchGuard (ExprStmt expr locn : stmts) ctx
+matchGuard (ExprStmt expr _ locn : stmts) ctx
   = matchGuard stmts ctx               `thenDs` \ match_result ->
     putSrcLocDs locn (dsExpr expr)     `thenDs` \ pred_expr ->
     returnDs (mkGuardedMatchResult pred_expr match_result)