X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FdeSugar%2FCheck.lhs;h=ace132cacd6906ff02cf51e130028cd231efc2b2;hb=74b27e20425336403d80e942ee3faf00f8c36ef8;hp=15fcf39405a7d54b0b54ca3d481f4cf0c25b9863;hpb=49c98d143c382a1341e1046f5ca00819a25691ba;p=ghc-hetmet.git diff --git a/compiler/deSugar/Check.lhs b/compiler/deSugar/Check.lhs index 15fcf39..ace132c 100644 --- a/compiler/deSugar/Check.lhs +++ b/compiler/deSugar/Check.lhs @@ -11,7 +11,6 @@ module Check ( check , ExhaustivePat ) where import HsSyn import TcHsSyn -import TcType import DsUtils import MatchLit import Id @@ -249,7 +248,7 @@ must be one Variable to be complete. process_literals :: [HsLit] -> [(EqnNo, EquationInfo)] -> ([ExhaustivePat],EqnSet) process_literals used_lits qs - | null default_eqns = ([make_row_vars used_lits (head qs)] ++ pats,indexs) + | null default_eqns = ASSERT( not (null qs) ) ([make_row_vars used_lits (head qs)] ++ pats,indexs) | otherwise = (pats_default,indexs_default) where (pats,indexs) = process_explicit_literals used_lits qs @@ -331,7 +330,7 @@ need_default_case used_cons unused_cons qs (pats',indexs') = check' default_eqns pats_default = [(make_whole_con c:ps,constraints) | c <- unused_cons, (ps,constraints) <- pats'] ++ pats - new_wilds = make_row_vars_for_constructor (head qs) + new_wilds = ASSERT( not (null qs) ) make_row_vars_for_constructor (head qs) pats_default_no_eqns = [(make_whole_con c:new_wilds,[]) | c <- unused_cons] ++ pats indexs_default = unionUniqSets indexs' indexs @@ -379,7 +378,7 @@ make_row_vars used_lits (_, EqnInfo { eqn_pats = pats}) hash_x = mkInternalName unboundKey {- doesn't matter much -} (mkVarOccFS FSLIT("#x")) - noSrcLoc + noSrcSpan make_row_vars_for_constructor :: (EqnNo, EquationInfo) -> [WarningPat] make_row_vars_for_constructor (_, EqnInfo { eqn_pats = pats}) @@ -424,6 +423,7 @@ get_lit :: Pat id -> Maybe HsLit get_lit (LitPat lit) = Just lit get_lit (NPat (HsIntegral i _) mb _ _) = Just (HsIntPrim (mb_neg mb i)) get_lit (NPat (HsFractional f _) mb _ _) = Just (HsFloatPrim (mb_neg mb f)) +get_lit (NPat (HsIsString s _) _ _ _) = Just (HsStringPrim s) get_lit other_pat = Nothing mb_neg :: Num a => Maybe b -> a -> a @@ -431,7 +431,7 @@ mb_neg Nothing v = v mb_neg (Just _) v = -v get_unused_cons :: [Pat Id] -> [DataCon] -get_unused_cons used_cons = unused_cons +get_unused_cons used_cons = ASSERT( not (null used_cons) ) unused_cons where (ConPatOut { pat_con = l_con, pat_ty = ty }) = head used_cons ty_con = dataConTyCon (unLoc l_con) -- Newtype observable @@ -608,7 +608,7 @@ has_nplusk_pat (PArrPat ps _) = any has_nplusk_lpat ps has_nplusk_pat (LazyPat p) = False -- Why? has_nplusk_pat (BangPat p) = has_nplusk_lpat p -- I think has_nplusk_pat (ConPatOut { pat_args = ps }) = any has_nplusk_lpat (hsConArgs ps) -has_nplusk_pat p = False -- VarPat, VarPatOut, WildPat, LitPat, NPat, TypePat, DictPat +has_nplusk_pat p = False -- VarPat, VarPatOut, WildPat, LitPat, NPat, TypePat simplify_lpat :: LPat Id -> LPat Id simplify_lpat p = fmap simplify_pat p @@ -661,15 +661,6 @@ simplify_pat (NPat lit mb_neg eq lit_ty) = tidyNPat lit mb_neg eq lit_ty simplify_pat (NPlusKPat id hslit hsexpr1 hsexpr2) = WildPat (idType (unLoc id)) -simplify_pat (DictPat dicts methods) - = case num_of_d_and_ms of - 0 -> simplify_pat (TuplePat [] Boxed unitTy) - 1 -> simplify_pat (head dict_and_method_pats) - _ -> simplify_pat (mkVanillaTuplePat (map noLoc dict_and_method_pats) Boxed) - where - num_of_d_and_ms = length dicts + length methods - dict_and_method_pats = map VarPat (dicts ++ methods) - simplify_pat (CoPat co pat ty) = simplify_pat pat -----------------