projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Comments only
[ghc-hetmet.git]
/
compiler
/
typecheck
/
TcSimplify.lhs
diff --git
a/compiler/typecheck/TcSimplify.lhs
b/compiler/typecheck/TcSimplify.lhs
index
708b8e4
..
95250f8
100644
(file)
--- a/
compiler/typecheck/TcSimplify.lhs
+++ b/
compiler/typecheck/TcSimplify.lhs
@@
-849,10
+849,11
@@
bindIrredsR loc qtvs co_vars reft givens irreds
-- The givens can include methods
-- See Note [Pruning the givens in an implication constraint]
-- The givens can include methods
-- See Note [Pruning the givens in an implication constraint]
- -- If there are no 'givens', then it's safe to
+ -- If there are no 'givens' *and* the refinement is empty
+ -- (the refinement is like more givens), then it's safe to
-- partition the 'wanteds' by their qtvs, thereby trimming irreds
-- See Note [Freeness and implications]
-- partition the 'wanteds' by their qtvs, thereby trimming irreds
-- See Note [Freeness and implications]
- ; irreds' <- if null givens'
+ ; irreds' <- if null givens' && isEmptyRefinement reft
then do
{ let qtv_set = mkVarSet qtvs
(frees, real_irreds) = partition (isFreeWrtTyVars qtv_set) irreds
then do
{ let qtv_set = mkVarSet qtvs
(frees, real_irreds) = partition (isFreeWrtTyVars qtv_set) irreds
@@
-862,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'
; 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 }
; extendLIEs implics
; return bind }
@@
-875,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
-- 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
--
-- This binding must line up the 'rhs' in reduceImplication
makeImplicationBind loc all_tvs reft
@@
-2256,7
+2260,12
@@
disambiguate extended_defaulting insts
-- use [Integer, Double]
do { integer_ty <- tcMetaTy integerTyConName
; checkWiredInTyCon doubleTyCon
-- 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
; traceTc (text "disambigutate" <+> vcat [ppr unaries, ppr bad_tvs, ppr defaultable_groups])
; mapM_ (disambigGroup default_tys) defaultable_groups }
where
@@
-2278,13
+2287,13
@@
disambiguate extended_defaulting insts
defaultable_classes clss
| extended_defaulting = any isInteractiveClass clss
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
-- 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
disambigGroup :: [Type] -- The default types