X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FdeSugar%2FCheck.lhs;h=6244b37bd6ec04c7e76985310697ce50fd72d3c7;hb=1fede4bc9501744bf2269ce2a4cb9fb735969caa;hp=75186feecbd736ee724111ebfb355a8b9780424a;hpb=0b957f9b7d093b563172d95dbf0b56878caeefd5;p=ghc-hetmet.git diff --git a/compiler/deSugar/Check.lhs b/compiler/deSugar/Check.lhs index 75186fe..6244b37 100644 --- a/compiler/deSugar/Check.lhs +++ b/compiler/deSugar/Check.lhs @@ -26,6 +26,8 @@ import Name import TysWiredIn import PrelNames import TyCon +import Type +import Unify( dataConCannotMatch ) import SrcLoc import UniqSet import Util @@ -433,11 +435,11 @@ get_lit :: Pat id -> Maybe HsLit -- Get a representative HsLit to stand for the OverLit -- It doesn't matter which one, because they will only be compared -- with other HsLits gotten in the same way -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 _ = Nothing +get_lit (LitPat lit) = Just lit +get_lit (NPat (OverLit { ol_val = HsIntegral i}) mb _) = Just (HsIntPrim (mb_neg mb i)) +get_lit (NPat (OverLit { ol_val = HsFractional f }) mb _) = Just (HsFloatPrim (mb_neg mb f)) +get_lit (NPat (OverLit { ol_val = HsIsString s }) _ _) = Just (HsStringPrim s) +get_lit _ = Nothing mb_neg :: Num a => Maybe b -> a -> a mb_neg Nothing v = v @@ -446,12 +448,13 @@ mb_neg (Just _) v = -v get_unused_cons :: [Pat Id] -> [DataCon] get_unused_cons used_cons = ASSERT( not (null used_cons) ) unused_cons where - (ConPatOut { pat_con = l_con }) = head used_cons - ty_con = dataConTyCon (unLoc l_con) -- Newtype observable - all_cons = tyConDataCons ty_con - used_cons_as_id = map (\ (ConPatOut{ pat_con = L _ d}) -> d) used_cons - unused_cons = uniqSetToList - (mkUniqSet all_cons `minusUniqSet` mkUniqSet used_cons_as_id) + used_set :: UniqSet DataCon + used_set = mkUniqSet [d | ConPatOut{ pat_con = L _ d} <- used_cons] + (ConPatOut { pat_ty = ty }) = head used_cons + Just (ty_con, inst_tys) = splitTyConApp_maybe ty + unused_cons = filterOut is_used (tyConDataCons ty_con) + is_used con = con `elementOfUniqSet` used_set + || dataConCannotMatch inst_tys con all_vars :: [Pat Id] -> Bool all_vars [] = True