-dsGRHSs :: DsMatchKind -> [TypecheckedPat] -- These are to build a MatchContext from
- -> [TypecheckedGRHS] -- Guarded RHSs
- -> DsM MatchResult
-
-dsGRHSs kind pats [grhs] = dsGRHS kind pats grhs
-
-dsGRHSs kind pats (grhs:grhss)
- = dsGRHS kind pats grhs `thenDs` \ match_result1 ->
- dsGRHSs kind pats grhss `thenDs` \ match_result2 ->
- returnDs (combineMatchResults match_result1 match_result2)
+dsGRHSs :: TypecheckedMatchContext -> [TypecheckedPat] -- These are to build a MatchContext from
+ -> TypecheckedGRHSs -- Guarded RHSs
+ -> DsM (Type, MatchResult)
+
+dsGRHSs kind pats (GRHSs grhss binds ty)
+ = mapDs (dsGRHS kind pats) grhss `thenDs` \ match_results ->
+ let
+ match_result1 = foldr1 combineMatchResults match_results
+ match_result2 = adjustMatchResultDs (dsLet binds) match_result1
+ -- NB: nested dsLet inside matchResult
+ in
+ returnDs (ty, match_result2)