X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FdeSugar%2FDsGRHSs.lhs;h=0aef3a6e4ded048a09524efaecb5f13c373d82e3;hb=7f4807640530a0e4d9d7efdeb6becee514274f02;hp=ab236f96d0a54bc792fd971a51de91f0492446b8;hpb=7c72bad588294734ecf3590247c67e47f8ba63fd;p=ghc-hetmet.git diff --git a/ghc/compiler/deSugar/DsGRHSs.lhs b/ghc/compiler/deSugar/DsGRHSs.lhs index ab236f9..0aef3a6 100644 --- a/ghc/compiler/deSugar/DsGRHSs.lhs +++ b/ghc/compiler/deSugar/DsGRHSs.lhs @@ -12,14 +12,16 @@ import {-# SOURCE #-} DsExpr ( dsExpr, dsLet ) import {-# SOURCE #-} Match ( matchSinglePat ) import HsSyn ( Stmt(..), HsExpr(..), GRHSs(..), GRHS(..), HsMatchContext(..) ) -import TcHsSyn ( TypecheckedGRHSs, TypecheckedPat, TypecheckedStmt ) +import TcHsSyn ( TypecheckedGRHSs, TypecheckedPat, TypecheckedStmt, TypecheckedMatchContext ) import CoreSyn ( CoreExpr ) 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. @@ -45,11 +47,11 @@ dsGuarded grhss In contrast, @dsGRHSs@ produces a @MatchResult@. \begin{code} -dsGRHSs :: HsMatchContext -> [TypecheckedPat] -- These are to build a MatchContext from - -> TypecheckedGRHSs -- Guarded RHSs +dsGRHSs :: TypecheckedMatchContext -> [TypecheckedPat] -- These are to build a MatchContext from + -> TypecheckedGRHSs -- Guarded RHSs -> DsM (Type, MatchResult) -dsGRHSs kind pats (GRHSs grhss binds (Just ty)) +dsGRHSs kind pats (GRHSs grhss binds ty) = mapDs (dsGRHS kind pats) grhss `thenDs` \ match_results -> let match_result1 = foldr1 combineMatchResults match_results @@ -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)