X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcSimplify.lhs;h=95250f8c6d81fb67d5fafaf1e4a08062c9339392;hb=ddf73c04de77994ad138771a7492007d794faf5e;hp=7b9f1f1b3f24cfdff99a39adbbf779c10f8cc4ea;hpb=d90023f2e54e2c0b5aad169d0f55748a152fecce;p=ghc-hetmet.git diff --git a/compiler/typecheck/TcSimplify.lhs b/compiler/typecheck/TcSimplify.lhs index 7b9f1f1..95250f8 100644 --- a/compiler/typecheck/TcSimplify.lhs +++ b/compiler/typecheck/TcSimplify.lhs @@ -863,7 +863,8 @@ bindIrredsR loc qtvs co_vars reft givens irreds ; let all_tvs = qtvs ++ co_vars -- Abstract over all these ; (implics, bind) <- makeImplicationBind loc all_tvs reft givens' irreds' - -- This call does the real work + -- This call does the real work + -- If irreds' is empty, it does something sensible ; extendLIEs implics ; return bind } @@ -876,6 +877,8 @@ makeImplicationBind :: InstLoc -> [TcTyVar] -> Refinement -- The binding looks like -- (ir1, .., irn) = f qtvs givens -- where f is (evidence for) the new implication constraint +-- f :: forall qtvs. {reft} givens => (ir1, .., irn) +-- qtvs includes coercion variables -- -- This binding must line up the 'rhs' in reduceImplication makeImplicationBind loc all_tvs reft @@ -2257,7 +2260,12 @@ disambiguate extended_defaulting insts -- use [Integer, Double] do { integer_ty <- tcMetaTy integerTyConName ; checkWiredInTyCon doubleTyCon - ; return [integer_ty, doubleTy] } + ; string_ty <- tcMetaTy stringTyConName + ; ovl_str <- doptM Opt_OverloadedStrings + ; if ovl_str -- Add String if -foverloaded-strings + then return [integer_ty,doubleTy,string_ty] + else return [integer_ty,doubleTy] } + ; traceTc (text "disambigutate" <+> vcat [ppr unaries, ppr bad_tvs, ppr defaultable_groups]) ; mapM_ (disambigGroup default_tys) defaultable_groups } where @@ -2279,13 +2287,13 @@ disambiguate extended_defaulting insts defaultable_classes clss | extended_defaulting = any isInteractiveClass clss - | otherwise = all isStandardClass clss && any isNumericClass clss + | otherwise = all isStandardClass clss && (any isNumericClass clss || any ((== isStringClassKey) . classKey) clss) -- In interactive mode, or with -fextended-default-rules, -- we default Show a to Show () to avoid graututious errors on "show []" isInteractiveClass cls = isNumericClass cls - || (classKey cls `elem` [showClassKey, eqClassKey, ordClassKey]) + || (classKey cls `elem` [showClassKey, eqClassKey, ordClassKey, isStringClassKey]) disambigGroup :: [Type] -- The default types