X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FdeSugar%2FMatchCon.lhs;h=bba9d42815bec4f1a98cf105e9a33d1951ffa1f6;hb=aedb94f5f220b5e442b23ecc445fd38c8d9b6ba0;hp=3bd8ff6ef6bc786a58574be59d7c49a09ab7ad92;hpb=ad94d40948668032189ad22a0ad741ac1f645f50;p=ghc-hetmet.git diff --git a/compiler/deSugar/MatchCon.lhs b/compiler/deSugar/MatchCon.lhs index 3bd8ff6..bba9d42 100644 --- a/compiler/deSugar/MatchCon.lhs +++ b/compiler/deSugar/MatchCon.lhs @@ -6,11 +6,11 @@ Pattern-matching constructors \begin{code} -{-# OPTIONS -w #-} +{-# OPTIONS -fno-warn-incomplete-patterns #-} -- The above warning supression flag is a temporary kludge. -- While working on this module you are encouraged to remove it and fix -- any warnings in the module. See --- http://hackage.haskell.org/trac/ghc/wiki/CodingStyle#Warnings +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings -- for details module MatchCon ( matchConFamily ) where @@ -25,10 +25,12 @@ import DataCon import TcType import Type import CoreSyn +import MkCore import DsMonad import DsUtils import Util ( takeList ) import Id +import Var (TyVar) import SrcLoc import Outputable \end{code} @@ -93,11 +95,15 @@ matchConFamily (var:vars) ty groups = do { alts <- mapM (matchOneCon vars ty) groups ; return (mkCoAlgCaseMatchResult var ty alts) } +matchOneCon :: [Id] + -> Type + -> [EquationInfo] + -> DsM (DataCon, [TyVar], MatchResult) matchOneCon vars ty (eqn1 : eqns) -- All eqns for a single constructor = do { (wraps, eqns') <- mapAndUnzipM shift (eqn1:eqns) ; arg_vars <- selectMatchVars (take (dataConSourceArity con1) (eqn_pats (head eqns'))) - -- Use the new arugment patterns as a source of + -- Use the new argument patterns as a source of -- suggestions for the new variables ; match_result <- match (arg_vars ++ vars) ty eqns' ; return (con1, tvs1 ++ dicts1 ++ arg_vars, @@ -119,7 +125,7 @@ matchOneCon vars ty (eqn1 : eqns) -- All eqns for a single constructor = do { prs <- dsLHsBinds bind ; return (wrapBinds (tvs `zip` tvs1) . wrapBinds (ds `zip` dicts1) - . mkDsLet (Rec prs), + . mkCoreLet (Rec prs), eqn { eqn_pats = conArgPats con1 arg_tys args ++ pats }) } conArgPats :: DataCon @@ -128,9 +134,9 @@ conArgPats :: DataCon -- are probably never looked at anyway -> HsConDetails (LPat Id) (HsRecFields Id (LPat Id)) -> [Pat Id] -conArgPats data_con arg_tys (PrefixCon ps) = map unLoc ps -conArgPats data_con arg_tys (InfixCon p1 p2) = [unLoc p1, unLoc p2] -conArgPats data_con arg_tys (RecCon (HsRecFields rpats _)) +conArgPats _data_con _arg_tys (PrefixCon ps) = map unLoc ps +conArgPats _data_con _arg_tys (InfixCon p1 p2) = [unLoc p1, unLoc p2] +conArgPats data_con arg_tys (RecCon (HsRecFields rpats _)) | null rpats = -- Special case for C {}, which can be used for -- a constructor that isn't declared to have