-
diff --git a/compiler/basicTypes/BasicTypes.lhs b/compiler/basicTypes/BasicTypes.lhs
index c6226ca..50434c6 100644
|
a
|
b
|
|
| 40 | 40 | compareFixity, |
| 41 | 41 | |
| 42 | 42 | IPName(..), ipNameName, mapIPName, |
| | 43 | HoleName(..), holeNameName, mapHoleName, |
| 43 | 44 | |
| 44 | 45 | RecFlag(..), isRec, isNonRec, boolToRecFlag, |
| 45 | 46 | |
| … |
… |
|
| 189 | 190 | |
| 190 | 191 | instance Outputable name => Outputable (IPName name) where |
| 191 | 192 | ppr (IPName n) = char '?' <> ppr n -- Ordinary implicit parameters |
| | 193 | |
| | 194 | |
| | 195 | newtype HoleName name = HoleName name -- _x |
| | 196 | deriving( Eq, Data, Typeable ) |
| | 197 | |
| | 198 | instance Ord a => Ord (HoleName a) where |
| | 199 | compare (HoleName a) (HoleName b) = compare a b |
| | 200 | |
| | 201 | instance Functor HoleName where |
| | 202 | fmap = mapHoleName |
| | 203 | |
| | 204 | holeNameName :: HoleName name -> name |
| | 205 | holeNameName (HoleName n) = n |
| | 206 | |
| | 207 | mapHoleName :: (a->b) -> HoleName a -> HoleName b |
| | 208 | mapHoleName f (HoleName n) = HoleName (f n) |
| | 209 | |
| | 210 | instance Outputable name => Outputable (HoleName name) where |
| | 211 | ppr (HoleName n) = char '_' <> ppr n -- Ordinary holes |
| | 212 | |
| 192 | 213 | \end{code} |
| 193 | 214 | |
| 194 | 215 | %************************************************************************ |
-
diff --git a/compiler/basicTypes/Unique.lhs b/compiler/basicTypes/Unique.lhs
index f99a50c..b81a5ad 100644
|
a
|
b
|
|
| 181 | 181 | |
| 182 | 182 | instance Uniquable n => Uniquable (IPName n) where |
| 183 | 183 | getUnique (IPName n) = getUnique n |
| | 184 | |
| | 185 | instance Uniquable n => Uniquable (HoleName n) where |
| | 186 | getUnique (HoleName n) = getUnique n |
| 184 | 187 | \end{code} |
| 185 | 188 | |
| 186 | 189 | |
-
diff --git a/compiler/deSugar/Coverage.lhs b/compiler/deSugar/Coverage.lhs
index 2d0ad23..9f4ee73 100644
|
a
|
b
|
|
| 540 | 540 | (addTickHsExpr e) -- explicitly no tick on inside |
| 541 | 541 | |
| 542 | 542 | addTickHsExpr e@(HsType _) = return e |
| | 543 | addTickHsExpr e@(HsHole _) = return e |
| 543 | 544 | |
| 544 | 545 | -- Others dhould never happen in expression content. |
| 545 | 546 | addTickHsExpr e = pprPanic "addTickHsExpr" (ppr e) |
-
diff --git a/compiler/deSugar/DsExpr.lhs b/compiler/deSugar/DsExpr.lhs
index b34640a..eba835a 100644
|
a
|
b
|
|
| 229 | 229 | |
| 230 | 230 | dsExpr (HsApp fun arg) |
| 231 | 231 | = mkCoreAppDs <$> dsLExpr fun <*> dsLExpr arg |
| | 232 | |
| | 233 | dsExpr (HsHole nm) |
| | 234 | = return (Var $ holeNameName nm) |
| 232 | 235 | \end{code} |
| 233 | 236 | |
| 234 | 237 | Note [Desugaring vars] |
-
diff --git a/compiler/hsSyn/HsExpr.lhs b/compiler/hsSyn/HsExpr.lhs
index 08d1281..90b9f59 100644
|
a
|
b
|
|
| 290 | 290 | |
| 291 | 291 | | HsWrap HsWrapper -- TRANSLATION |
| 292 | 292 | (HsExpr id) |
| | 293 | | HsHole (HoleName id) |
| 293 | 294 | deriving (Data, Typeable) |
| 294 | 295 | |
| 295 | 296 | -- HsTupArg is used for tuple sections |
| … |
… |
|
| 545 | 546 | ppr_expr (HsArrForm op _ args) |
| 546 | 547 | = hang (ptext (sLit "(|") <> ppr_lexpr op) |
| 547 | 548 | 4 (sep (map (pprCmdArg.unLoc) args) <> ptext (sLit "|)")) |
| | 549 | ppr_expr (HsHole name) |
| | 550 | = ppr name |
| 548 | 551 | |
| 549 | 552 | pprCmdArg :: OutputableBndr id => HsCmdTop id -> SDoc |
| 550 | 553 | pprCmdArg (HsCmdTop cmd@(L _ (HsArrForm _ Nothing [])) _ _ _) |
-
diff --git a/compiler/iface/IfaceEnv.lhs b/compiler/iface/IfaceEnv.lhs
index 4c66a98..de43a89 100644
|
a
|
b
|
|
| 12 | 12 | newGlobalBinder, newImplicitBinder, |
| 13 | 13 | lookupIfaceTop, |
| 14 | 14 | lookupOrig, lookupOrigNameCache, extendNameCache, |
| 15 | | newIPName, newIfaceName, newIfaceNames, |
| | 15 | newIPName, newHoleName, newIfaceName, newIfaceNames, |
| 16 | 16 | extendIfaceIdEnv, extendIfaceTyVarEnv, |
| 17 | 17 | tcIfaceLclId, tcIfaceTyVar, lookupIfaceTyVar, |
| 18 | 18 | |
| … |
… |
|
| 42 | 42 | import SrcLoc |
| 43 | 43 | import BasicTypes |
| 44 | 44 | |
| | 45 | import TysPrim |
| | 46 | import TysWiredIn |
| | 47 | import Coercion |
| | 48 | |
| 45 | 49 | import Outputable |
| 46 | 50 | import Exception ( evaluate ) |
| 47 | 51 | |
| … |
… |
|
| 181 | 185 | newIPName ip = updNameCache $ flip allocateIPName ip |
| 182 | 186 | \end{code} |
| 183 | 187 | |
| | 188 | \begin{code} |
| | 189 | newHoleName :: FastString -> TcRnIf m n (HoleName Name) |
| | 190 | newHoleName name = updNameCache $ \name_cache -> case Map.lookup name $ nsHoles name_cache of |
| | 191 | Just name_hole -> (name_cache, name_hole) |
| | 192 | Nothing -> (new_ns, name_hole) |
| | 193 | where |
| | 194 | (us_here, us') = splitUniqSupply (nsUniqs name_cache) |
| | 195 | new_holecache = Map.insert name name_hole $ nsHoles name_cache |
| | 196 | tycon_u:datacon_u:dc_wrk_u:co_ax_u:_ = uniqsFromSupply us_here |
| | 197 | name_hole = mkHoleName name tycon_u datacon_u dc_wrk_u co_ax_u |
| | 198 | new_ns = name_cache { nsUniqs = us', nsHoles = new_holecache } |
| | 199 | |
| | 200 | \end{code} |
| | 201 | |
| 184 | 202 | %************************************************************************ |
| 185 | 203 | %* * |
| 186 | 204 | Name cache access |
| … |
… |
|
| 249 | 267 | initNameCache us names |
| 250 | 268 | = NameCache { nsUniqs = us, |
| 251 | 269 | nsNames = initOrigNames names, |
| 252 | | nsIPs = Map.empty } |
| | 270 | nsIPs = Map.empty, |
| | 271 | nsHoles = Map.empty } |
| 253 | 272 | |
| 254 | 273 | initOrigNames :: [Name] -> OrigNameCache |
| 255 | 274 | initOrigNames names = foldl extendOrigNameCache emptyModuleEnv names |
-
diff --git a/compiler/main/HscTypes.lhs b/compiler/main/HscTypes.lhs
index e0eea7d..4382532 100644
|
a
|
b
|
|
| 1762 | 1762 | -- ^ Supply of uniques |
| 1763 | 1763 | nsNames :: OrigNameCache, |
| 1764 | 1764 | -- ^ Ensures that one original name gets one unique |
| 1765 | | nsIPs :: OrigIParamCache |
| | 1765 | nsIPs :: OrigIParamCache, |
| 1766 | 1766 | -- ^ Ensures that one implicit parameter name gets one unique |
| | 1767 | nsHoles :: OrigHoleCache |
| 1767 | 1768 | } |
| 1768 | 1769 | |
| 1769 | 1770 | -- | Per-module cache of original 'OccName's given 'Name's |
| … |
… |
|
| 1771 | 1772 | |
| 1772 | 1773 | -- | Module-local cache of implicit parameter 'OccName's given 'Name's |
| 1773 | 1774 | type OrigIParamCache = Map FastString (IPName Name) |
| | 1775 | |
| | 1776 | type OrigHoleCache = Map FastString (HoleName Name) |
| 1774 | 1777 | \end{code} |
| 1775 | 1778 | |
| 1776 | 1779 | |
-
diff --git a/compiler/main/InteractiveEval.hs b/compiler/main/InteractiveEval.hs
index b62ec40..c466c72 100644
|
a
|
b
|
|
| 932 | 932 | exprType :: GhcMonad m => String -> m Type |
| 933 | 933 | exprType expr = withSession $ \hsc_env -> do |
| 934 | 934 | ty <- liftIO $ hscTcExpr hsc_env expr |
| 935 | | return $ tidyType emptyTidyEnv ty |
| | 935 | return {-$ tidyType emptyTidyEnv-} ty |
| 936 | 936 | |
| 937 | 937 | -- ----------------------------------------------------------------------------- |
| 938 | 938 | -- Getting the kind of a type |
-
diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x
index 74da99a..d1139a2 100644
|
a
|
b
|
|
| 105 | 105 | |
| 106 | 106 | $unismall = \x02 -- Trick Alex into handling Unicode. See alexGetChar. |
| 107 | 107 | $ascsmall = [a-z] |
| 108 | | $small = [$ascsmall $unismall \_] |
| | 108 | $small = [$ascsmall $unismall] |
| 109 | 109 | |
| 110 | 110 | $unigraphic = \x06 -- Trick Alex into handling Unicode. See alexGetChar. |
| 111 | 111 | $graphic = [$small $large $symbol $digit $special $unigraphic \:\"\'] |
| … |
… |
|
| 338 | 338 | { token ITcubxparen } |
| 339 | 339 | } |
| 340 | 340 | |
| | 341 | <0> { |
| | 342 | \_ @varid { skip_one_varid IThole } |
| | 343 | } |
| | 344 | |
| 341 | 345 | <0,option_prags> { |
| 342 | 346 | \( { special IToparen } |
| 343 | 347 | \) { special ITcparen } |
| … |
… |
|
| 538 | 542 | | ITprefixqconsym (FastString,FastString) |
| 539 | 543 | |
| 540 | 544 | | ITdupipvarid FastString -- GHC extension: implicit param: ?x |
| | 545 | | IThole FastString |
| 541 | 546 | |
| 542 | 547 | | ITchar Char |
| 543 | 548 | | ITstring FastString |
-
diff --git a/compiler/parser/Parser.y.pp b/compiler/parser/Parser.y.pp
index ff98b74..cfd964a 100644
|
a
|
b
|
|
| 322 | 322 | PREFIXQCONSYM { L _ (ITprefixqconsym _) } |
| 323 | 323 | |
| 324 | 324 | IPDUPVARID { L _ (ITdupipvarid _) } -- GHC extension |
| | 325 | HOLEVARID { L _ (IThole _) } |
| 325 | 326 | |
| 326 | 327 | CHAR { L _ (ITchar _) } |
| 327 | 328 | STRING { L _ (ITstring _) } |
| … |
… |
|
| 1436 | 1437 | |
| 1437 | 1438 | aexp2 :: { LHsExpr RdrName } |
| 1438 | 1439 | : ipvar { L1 (HsIPVar $! unLoc $1) } |
| | 1440 | | hole { L1 (HsHole $! unLoc $1) } |
| 1439 | 1441 | | qcname { L1 (HsVar $! unLoc $1) } |
| 1440 | 1442 | | literal { L1 (HsLit $! unLoc $1) } |
| 1441 | 1443 | -- This will enable overloaded strings permanently. Normally the renamer turns HsString |
| … |
… |
|
| 1750 | 1752 | ipvar :: { Located (IPName RdrName) } |
| 1751 | 1753 | : IPDUPVARID { L1 (IPName (mkUnqual varName (getIPDUPVARID $1))) } |
| 1752 | 1754 | |
| | 1755 | hole :: { Located (HoleName RdrName) } |
| | 1756 | : HOLEVARID { L1 (HoleName (mkUnqual varName $ getHOLEVARID $1)) } |
| | 1757 | |
| 1753 | 1758 | ----------------------------------------------------------------------------- |
| 1754 | 1759 | -- Warnings and deprecations |
| 1755 | 1760 | |
| … |
… |
|
| 2069 | 2074 | getPREFIXQVARSYM (L _ (ITprefixqvarsym x)) = x |
| 2070 | 2075 | getPREFIXQCONSYM (L _ (ITprefixqconsym x)) = x |
| 2071 | 2076 | getIPDUPVARID (L _ (ITdupipvarid x)) = x |
| | 2077 | getHOLEVARID (L _ (IThole x)) = x |
| 2072 | 2078 | getCHAR (L _ (ITchar x)) = x |
| 2073 | 2079 | getSTRING (L _ (ITstring x)) = x |
| 2074 | 2080 | getINTEGER (L _ (ITinteger x)) = x |
-
diff --git a/compiler/prelude/TysWiredIn.lhs b/compiler/prelude/TysWiredIn.lhs
index 7d4edfd..15e4f26 100644
|
a
|
b
|
|
| 73 | 73 | eqTyCon_RDR, eqTyCon, eqTyConName, eqBoxDataCon, |
| 74 | 74 | |
| 75 | 75 | -- * Implicit parameter predicates |
| 76 | | mkIPName |
| | 76 | mkIPName, |
| | 77 | |
| | 78 | mkHoleName |
| 77 | 79 | ) where |
| 78 | 80 | |
| 79 | 81 | #include "HsVersions.h" |
| … |
… |
|
| 94 | 96 | import TypeRep |
| 95 | 97 | import RdrName |
| 96 | 98 | import Name |
| 97 | | import BasicTypes ( TupleSort(..), tupleSortBoxity, IPName(..), |
| | 99 | import BasicTypes ( TupleSort(..), tupleSortBoxity, IPName(..), HoleName(..), |
| 98 | 100 | Arity, RecFlag(..), Boxity(..), HsBang(..) ) |
| 99 | 101 | import ForeignCall |
| 100 | 102 | import Unique ( incrUnique, mkTupleTyConUnique, |
| … |
… |
|
| 424 | 426 | co_ax_name = mkPrimTyConName ip co_ax_u tycon |
| 425 | 427 | \end{code} |
| 426 | 428 | |
| | 429 | \begin{code} |
| | 430 | mkHoleName :: FastString |
| | 431 | -> Unique -> Unique -> Unique -> Unique |
| | 432 | -> HoleName Name |
| | 433 | mkHoleName ip tycon_u datacon_u dc_wrk_u co_ax_u = name_hole |
| | 434 | where |
| | 435 | name_hole = HoleName tycon_name |
| | 436 | |
| | 437 | tycon_name = mkPrimTyConName ip tycon_u tycon |
| | 438 | tycon = mkAlgTyCon tycon_name |
| | 439 | (liftedTypeKind `mkArrowKind` constraintKind) |
| | 440 | [alphaTyVar] |
| | 441 | Nothing |
| | 442 | [] -- No stupid theta |
| | 443 | (NewTyCon { data_con = datacon, |
| | 444 | nt_rhs = mkTyVarTy alphaTyVar, |
| | 445 | nt_etad_rhs = ([alphaTyVar], mkTyVarTy alphaTyVar), |
| | 446 | nt_co = mkNewTypeCo co_ax_name tycon [alphaTyVar] (mkTyVarTy alphaTyVar) }) |
| | 447 | (HoleTyCon name_hole) |
| | 448 | NonRecursive |
| | 449 | False |
| | 450 | |
| | 451 | datacon_name = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "IPBox") datacon_u datacon |
| | 452 | datacon = pcDataCon' datacon_name dc_wrk_u [alphaTyVar] [mkTyVarTy alphaTyVar] tycon |
| | 453 | |
| | 454 | co_ax_name = mkPrimTyConName ip co_ax_u tycon |
| | 455 | \end{code} |
| | 456 | |
| 427 | 457 | %************************************************************************ |
| 428 | 458 | %* * |
| 429 | 459 | \subsection[TysWiredIn-boxed-prim]{The ``boxed primitive'' types (@Char@, @Int@, etc)} |
-
diff --git a/compiler/rename/RnExpr.lhs b/compiler/rename/RnExpr.lhs
index 7caae61..d5ddff9 100644
|
a
|
b
|
|
| 34 | 34 | import TcRnMonad |
| 35 | 35 | import TcEnv ( thRnBrack ) |
| 36 | 36 | import RnEnv |
| 37 | | import RnTypes ( rnHsTypeFVs, rnSplice, rnIPName, checkTH, |
| | 37 | import RnTypes ( rnHsTypeFVs, rnSplice, rnIPName, rnHoleName, checkTH, |
| 38 | 38 | mkOpFormRn, mkOpAppRn, mkNegAppRn, checkSectionPrec) |
| 39 | 39 | import RnPat |
| 40 | 40 | import DynFlags |
| … |
… |
|
| 293 | 293 | rnExpr (PArrSeq _ seq) |
| 294 | 294 | = rnArithSeq seq `thenM` \ (new_seq, fvs) -> |
| 295 | 295 | return (PArrSeq noPostTcExpr new_seq, fvs) |
| | 296 | |
| | 297 | rnExpr (HsHole name) |
| | 298 | = do { name' <- rnHoleName name |
| | 299 | ; return (HsHole name', emptyFVs) |
| | 300 | } |
| 296 | 301 | \end{code} |
| 297 | 302 | |
| 298 | 303 | These three are pattern syntax appearing in expressions. |
-
diff --git a/compiler/rename/RnTypes.lhs b/compiler/rename/RnTypes.lhs
index 3b86d0b..78c0bb7 100644
|
a
|
b
|
|
| 16 | 16 | rnHsType, rnLHsType, rnLHsTypes, rnContext, |
| 17 | 17 | rnHsKind, rnLHsKind, rnLHsMaybeKind, |
| 18 | 18 | rnHsSigType, rnLHsInstType, rnHsTypeFVs, rnConDeclFields, |
| 19 | | rnIPName, |
| | 19 | rnIPName, rnHoleName, |
| 20 | 20 | |
| 21 | 21 | -- Precence related stuff |
| 22 | 22 | mkOpAppRn, mkNegAppRn, mkOpFormRn, mkConOpPatRn, |
| … |
… |
|
| 41 | 41 | import RnHsDoc ( rnLHsDoc, rnMbLHsDoc ) |
| 42 | 42 | import RnEnv |
| 43 | 43 | import TcRnMonad |
| 44 | | import IfaceEnv ( newIPName ) |
| | 44 | import IfaceEnv ( newIPName, newHoleName ) |
| 45 | 45 | import RdrName |
| 46 | 46 | import PrelNames |
| 47 | 47 | import TysPrim ( funTyConName ) |
| … |
… |
|
| 51 | 51 | |
| 52 | 52 | import Util ( filterOut ) |
| 53 | 53 | import BasicTypes ( IPName(..), ipNameName, compareFixity, funTyFixity, negateFixity, |
| 54 | | Fixity(..), FixityDirection(..) ) |
| | 54 | Fixity(..), FixityDirection(..), HoleName(..), holeNameName ) |
| 55 | 55 | import Outputable |
| 56 | 56 | import FastString |
| 57 | 57 | import Control.Monad ( unless, zipWithM ) |
| … |
… |
|
| 344 | 344 | rnIPName n = newIPName (occNameFS (rdrNameOcc (ipNameName n))) |
| 345 | 345 | \end{code} |
| 346 | 346 | |
| | 347 | \begin{code} |
| | 348 | rnHoleName :: HoleName RdrName -> RnM (HoleName Name) |
| | 349 | rnHoleName n = newHoleName (occNameFS (rdrNameOcc (holeNameName n))) |
| | 350 | \end{code} |
| | 351 | |
| 347 | 352 | |
| 348 | 353 | %************************************************************************ |
| 349 | 354 | %* * |
-
diff --git a/compiler/typecheck/Inst.lhs b/compiler/typecheck/Inst.lhs
index a194d74..437b50e 100644
|
a
|
b
|
|
| 519 | 519 | has_eq' (ClassPred cls _tys) = any has_eq (classSCTheta cls) |
| 520 | 520 | has_eq' (TuplePred ts) = any has_eq ts |
| 521 | 521 | has_eq' (IrredPred _) = True -- Might have equalities in it after reduction? |
| | 522 | has_eq' (HolePred {}) = False |
| 522 | 523 | |
| 523 | 524 | ---------------- Getting free tyvars ------------------------- |
| 524 | 525 | |
| … |
… |
|
| 529 | 530 | tyVarsOfCt (CIPCan { cc_ip_ty = ty }) = tyVarsOfType ty |
| 530 | 531 | tyVarsOfCt (CIrredEvCan { cc_ty = ty }) = tyVarsOfType ty |
| 531 | 532 | tyVarsOfCt (CNonCanonical { cc_id = ev }) = tyVarsOfEvVar ev |
| | 533 | tyVarsOfCt (CHoleCan { cc_hole_ty = ty }) = tyVarsOfType ty |
| 532 | 534 | |
| 533 | 535 | tyVarsOfCDict :: Ct -> TcTyVarSet |
| 534 | 536 | tyVarsOfCDict (CDictCan { cc_tyargs = tys }) = tyVarsOfTypes tys |
-
diff --git a/compiler/typecheck/TcCanonical.lhs b/compiler/typecheck/TcCanonical.lhs
index c765dde..28e86a3 100644
|
a
|
b
|
|
| 13 | 13 | |
| 14 | 14 | #include "HsVersions.h" |
| 15 | 15 | |
| 16 | | import BasicTypes ( IPName ) |
| | 16 | import BasicTypes ( IPName, HoleName ) |
| 17 | 17 | import TcErrors |
| 18 | 18 | import TcRnTypes |
| 19 | 19 | import TcType |
| … |
… |
|
| 37 | 37 | import TcSMonad |
| 38 | 38 | import FastString |
| 39 | 39 | |
| | 40 | import qualified TcMType |
| | 41 | |
| 40 | 42 | import Data.Maybe ( isNothing ) |
| 41 | 43 | import Data.List ( zip4 ) |
| 42 | 44 | \end{code} |
| … |
… |
|
| 204 | 206 | , cc_depth = d |
| 205 | 207 | , cc_ty = xi }) |
| 206 | 208 | = canIrred d fl ev xi |
| | 209 | canonicalize (CHoleCan { cc_id = ev, cc_depth = d |
| | 210 | , cc_flavor = fl |
| | 211 | , cc_hole_nm = nm |
| | 212 | , cc_hole_ty = xi }) |
| | 213 | = canHole d fl ev nm xi |
| 207 | 214 | |
| 208 | 215 | |
| 209 | 216 | canEvVar :: EvVar -> PredTree |
| … |
… |
|
| 216 | 223 | IPPred nm ty -> canIP d fl ev nm ty |
| 217 | 224 | IrredPred ev_ty -> canIrred d fl ev ev_ty |
| 218 | 225 | TuplePred tys -> canTuple d fl ev tys |
| | 226 | HolePred name ty -> canHole d fl ev name ty |
| 219 | 227 | \end{code} |
| 220 | 228 | |
| 221 | 229 | |
| … |
… |
|
| 263 | 271 | = -- Note [Canonical implicit parameter constraints] explains why it's |
| 264 | 272 | -- possible in principle to not flatten, but since flattening applies |
| 265 | 273 | -- the inert substitution we choose to flatten anyway. |
| 266 | | do { (xi,co) <- flatten d fl (mkIPPred nm ty) |
| | 274 | do { (xi,co) <- trace "canIP" $ flatten d fl (mkIPPred nm ty) |
| 267 | 275 | ; let no_flattening = isTcReflCo co |
| 268 | 276 | ; if no_flattening then |
| 269 | 277 | let IPPred _ xi_in = classifyPredType xi |
| … |
… |
|
| 296 | 304 | class constraints for the same class MAY be equal, so they need to be |
| 297 | 305 | flattened in the first place to facilitate comparing them.) |
| 298 | 306 | |
| | 307 | \begin{code} |
| | 308 | canHole :: SubGoalDepth -- Depth |
| | 309 | -> CtFlavor -> EvVar |
| | 310 | -> HoleName Name -> Type -> TcS StopOrContinue |
| | 311 | canHole d fl v nm ty |
| | 312 | = do { (xi,co) <- flatten d fl (mkHolePred nm ty) |
| | 313 | ; let no_flattening = isTcReflCo co |
| | 314 | ; if no_flattening then |
| | 315 | let HolePred _ xi_in = classifyPredType xi |
| | 316 | in continueWith $ CHoleCan { cc_id = v, cc_flavor = fl |
| | 317 | , cc_hole_nm = nm, cc_hole_ty = xi_in |
| | 318 | , cc_depth = d |
| | 319 | } |
| | 320 | else |
| | 321 | error "false" |
| | 322 | } |
| | 323 | \end{code} |
| | 324 | |
| 299 | 325 | %************************************************************************ |
| 300 | 326 | %* * |
| 301 | 327 | %* Class Canonicalization |
-
diff --git a/compiler/typecheck/TcErrors.lhs b/compiler/typecheck/TcErrors.lhs
index cb388ff..2831218 100644
|
a
|
b
|
|
| 294 | 294 | ClassPred {} -> go cts (ct:dicts) ips irreds |
| 295 | 295 | IPPred {} -> go cts dicts (ct:ips) irreds |
| 296 | 296 | IrredPred {} -> go cts dicts ips (ct:irreds) |
| | 297 | HolePred {} -> go cts dicts ips irreds |
| 297 | 298 | _ -> panic "mkFlat" |
| 298 | 299 | -- TuplePreds should have been expanded away by the constraint |
| 299 | 300 | -- simplifier, so they shouldn't show up at this point |
-
diff --git a/compiler/typecheck/TcExpr.lhs b/compiler/typecheck/TcExpr.lhs
index 488e654..67a10ae 100644
|
a
|
b
|
|
| 63 | 63 | import Outputable |
| 64 | 64 | import FastString |
| 65 | 65 | import Control.Monad |
| | 66 | |
| | 67 | import TypeRep |
| | 68 | import qualified Data.Map as Map |
| 66 | 69 | \end{code} |
| 67 | 70 | |
| 68 | 71 | %************************************************************************ |
| … |
… |
|
| 90 | 93 | = do { traceTc "tcPolyExprNC" (ppr res_ty) |
| 91 | 94 | ; (gen_fn, expr') <- tcGen GenSigCtxt res_ty $ \ _ rho -> |
| 92 | 95 | tcMonoExprNC expr rho |
| | 96 | ; sk <- deeplySkolemise res_ty |
| 93 | 97 | ; return (mkLHsWrap gen_fn expr') } |
| 94 | 98 | |
| 95 | 99 | --------------- |
| … |
… |
|
| 214 | 218 | -- so it's not enabled yet. |
| 215 | 219 | -- Can't eliminate it altogether from the parser, because the |
| 216 | 220 | -- same parser parses *patterns*. |
| | 221 | tcExpr (HsHole name) res_ty |
| | 222 | = do { traceTc "tcExpr.HsHole" (ppr $ res_ty) |
| | 223 | ; let origin = OccurrenceOf $ holeNameName name |
| | 224 | -- Update the local environment with our ty |
| | 225 | ; (g, l) <- getEnvs |
| | 226 | ; holes <- readTcRef $ tcl_holes l |
| | 227 | ; ty <- newFlexiTyVarTy liftedTypeKind |
| | 228 | |
| | 229 | -- Emit the constraint |
| | 230 | ; var <- emitWanted origin (mkHolePred name ty) |
| | 231 | ; traceTc "tcExpr.HsHole: Creating new ty for hole" (ppr ty) |
| | 232 | ; writeTcRef (tcl_holes l) (Map.insert name (ty, tcl_lie l) holes) |
| | 233 | |
| | 234 | ; tcWrapResult (HsHole $ HoleName var) ty res_ty } |
| 217 | 235 | \end{code} |
| 218 | 236 | |
| 219 | 237 | |
-
diff --git a/compiler/typecheck/TcHsSyn.lhs b/compiler/typecheck/TcHsSyn.lhs
index d99bd81..1232a0f 100644
|
a
|
b
|
|
| 703 | 703 | zonkExpr env1 expr `thenM` \ new_expr -> |
| 704 | 704 | return (HsWrap new_co_fn new_expr) |
| 705 | 705 | |
| | 706 | zonkExpr env h@(HsHole nm) |
| | 707 | = do { |
| | 708 | traceTc "zonkExpr.HsHole" (ppr h); |
| | 709 | return (HsHole nm) |
| | 710 | } |
| | 711 | |
| 706 | 712 | zonkExpr _ expr = pprPanic "zonkExpr" (ppr expr) |
| 707 | 713 | |
| 708 | 714 | zonkCmdTop :: ZonkEnv -> LHsCmdTop TcId -> TcM (LHsCmdTop Id) |
-
diff --git a/compiler/typecheck/TcInteract.lhs b/compiler/typecheck/TcInteract.lhs
index 3e58013..3dc1744 100644
|
a
|
b
|
|
| 56 | 56 | import UniqFM |
| 57 | 57 | import FastString ( sLit ) |
| 58 | 58 | import DynFlags |
| | 59 | |
| | 60 | import Control.Monad |
| | 61 | import Type |
| 59 | 62 | \end{code} |
| 60 | 63 | ********************************************************************** |
| 61 | 64 | * * |
| … |
… |
|
| 415 | 418 | , inert_funeqs = funeqmap |
| 416 | 419 | , inert_irreds = irreds |
| 417 | 420 | , inert_frozen = frozen |
| | 421 | , inert_holes = holemap |
| 418 | 422 | } ) |
| 419 | 423 | = ((kicked_out, eqmap), remaining) |
| 420 | 424 | where |
| 421 | 425 | kicked_out = WorkList { wl_eqs = [] |
| 422 | 426 | , wl_funeqs = bagToList feqs_out |
| 423 | 427 | , wl_rest = bagToList (fro_out `andCts` dicts_out |
| 424 | | `andCts` ips_out `andCts` irs_out) } |
| | 428 | `andCts` ips_out `andCts` irs_out `andCts` holes_out) } |
| 425 | 429 | |
| 426 | 430 | remaining = IS { inert_eqs = emptyVarEnv |
| 427 | 431 | , inert_eq_tvs = inscope -- keep the same, safe and cheap |
| … |
… |
|
| 430 | 434 | , inert_funeqs = feqs_in |
| 431 | 435 | , inert_irreds = irs_in |
| 432 | 436 | , inert_frozen = fro_in |
| | 437 | , inert_holes = holes_in |
| 433 | 438 | } |
| 434 | 439 | |
| 435 | 440 | fl = cc_flavor ct |
| 436 | 441 | tv = cc_tyvar ct |
| 437 | 442 | |
| 438 | 443 | (ips_out, ips_in) = partitionCCanMap rewritable ipmap |
| | 444 | (holes_out, holes_in) = partitionCCanMap rewritable holemap |
| 439 | 445 | |
| 440 | 446 | (feqs_out, feqs_in) = partitionCtTypeMap rewritable funeqmap |
| 441 | 447 | (dicts_out, dicts_in) = partitionCCanMap rewritable dictmap |
| … |
… |
|
| 686 | 692 | | IRInertConsumed { ir_fire :: String } |
| 687 | 693 | | IRKeepGoing { ir_fire :: String } |
| 688 | 694 | |
| | 695 | |
| | 696 | instance Outputable InteractResult where |
| | 697 | ppr (IRWorkItemConsumed str) = ptext (sLit "IRWorkItemConsumed ") <+> text str |
| | 698 | ppr (IRInertConsumed str) = ptext (sLit "IRInertConsumed ") <+> text str |
| | 699 | ppr (IRKeepGoing str) = ptext (sLit "IRKeepGoing ") <+> text str |
| | 700 | |
| 689 | 701 | irWorkItemConsumed :: String -> TcS InteractResult |
| 690 | 702 | irWorkItemConsumed str = return (IRWorkItemConsumed str) |
| 691 | 703 | |
| … |
… |
|
| 703 | 715 | -- react with anything at this stage. |
| 704 | 716 | interactWithInertsStage wi |
| 705 | 717 | = do { ctxt <- getTcSContext |
| | 718 | ; traceTcS "interactWithInertsStage" (ppr $ simplEqsOnly ctxt) |
| 706 | 719 | ; if simplEqsOnly ctxt then |
| 707 | 720 | return (ContinueWith wi) |
| 708 | 721 | else |
| 709 | | extractRelevantInerts wi >>= |
| 710 | | foldlBagM interact_next (ContinueWith wi) } |
| | 722 | do { relevant <- extractRelevantInerts wi |
| | 723 | ; traceTcS "interactWithInertsStage: Relevant" (ppr relevant) |
| | 724 | ; foldlBagM interact_next (ContinueWith wi) relevant |
| | 725 | } |
| | 726 | } |
| 711 | 727 | |
| 712 | 728 | where interact_next Stop atomic_inert |
| 713 | | = updInertSetTcS atomic_inert >> return Stop |
| | 729 | = trace "interact_next Stop" $ updInertSetTcS atomic_inert >> return Stop |
| 714 | 730 | interact_next (ContinueWith wi) atomic_inert |
| 715 | 731 | = do { ir <- doInteractWithInert atomic_inert wi |
| 716 | 732 | ; let mk_msg rule keep_doc |
| 717 | 733 | = text rule <+> keep_doc |
| 718 | 734 | <+> vcat [ ptext (sLit "Inert =") <+> ppr atomic_inert |
| 719 | 735 | , ptext (sLit "Work =") <+> ppr wi ] |
| | 736 | ; traceTcS "interact_next ContinueWith" (ppr ir) |
| 720 | 737 | ; case ir of |
| 721 | 738 | IRWorkItemConsumed { ir_fire = rule } |
| 722 | 739 | -> do { bumpStepCountTcS |
| … |
… |
|
| 851 | 868 | where |
| 852 | 869 | lhss_match = tc1 == tc2 && eqTypes args1 args2 |
| 853 | 870 | |
| | 871 | doInteractWithInert (CHoleCan id1 fl1 nm1 ty1 d1) workitem@(CHoleCan id2 fl2 nm2 ty2 d2) |
| | 872 | | nm1 == nm2 && isGivenOrSolved fl2 && isGivenOrSolved fl1 |
| | 873 | = irInertConsumed "Hole/Hole (override inert)" |
| | 874 | | nm1 == nm2 && ty1 `eqType` ty2 |
| | 875 | = solveOneFromTheOther "Hole/Hole" (EvId id1,fl1) workitem |
| 854 | 876 | |
| | 877 | | nm1 == nm2 |
| | 878 | = do { let flav = Wanted (combineCtLoc fl1 fl2) |
| | 879 | ; eqv <- newEqVar flav ty2 ty1 |
| | 880 | ; when (isNewEvVar eqv) $ |
| | 881 | (let ct = CNonCanonical { cc_id = evc_the_evvar eqv |
| | 882 | , cc_flavor = flav |
| | 883 | , cc_depth = d2 } |
| | 884 | in updWorkListTcS (extendWorkListEq ct)) |
| | 885 | ; case fl2 of |
| | 886 | Given {} -> pprPanic "Unexpected given Hole" (ppr workitem) |
| | 887 | Derived {} -> pprPanic "Unexpected derived Hole" (ppr workitem) |
| | 888 | Wanted {} -> |
| | 889 | do { _ <- setEvBind id2 |
| | 890 | (mkEvCast id1 (mkTcSymCo (mkTcTyConAppCo (holeTyCon nm1) [mkTcCoVarCo (evc_the_evvar eqv)]))) fl2 |
| | 891 | ; irWorkItemConsumed "Hole/Hole (solved by rewriting)" } |
| | 892 | } |
| 855 | 893 | doInteractWithInert _ _ = irKeepGoing "NOP" |
| 856 | 894 | |
| 857 | 895 | |
-
diff --git a/compiler/typecheck/TcMType.lhs b/compiler/typecheck/TcMType.lhs
index 518a403..b9b6c50 100644
|
a
|
b
|
|
| 167 | 167 | predTypeOccName ty = case classifyPredType ty of |
| 168 | 168 | ClassPred cls _ -> mkDictOcc (getOccName cls) |
| 169 | 169 | IPPred ip _ -> mkVarOccFS (ipFastString ip) |
| | 170 | HolePred name _ -> mkVarOccFS (occNameFS $ nameOccName $ holeNameName name) |
| 170 | 171 | EqPred _ _ -> mkVarOccFS (fsLit "cobox") |
| 171 | 172 | TuplePred _ -> mkVarOccFS (fsLit "tup") |
| 172 | 173 | IrredPred _ -> mkVarOccFS (fsLit "irred") |
| … |
… |
|
| 1386 | 1387 | go (EqPred ty1 ty2) = grow (tyVarsOfType ty1 `unionVarSet` tyVarsOfType ty2) |
| 1387 | 1388 | go (TuplePred ts) = unionVarSets (map (go . classifyPredType) ts) |
| 1388 | 1389 | go (IrredPred ty) = grow (tyVarsOfType ty) |
| | 1390 | go (HolePred _ ty) = tyVarsOfType ty |
| 1389 | 1391 | \end{code} |
| 1390 | 1392 | |
| 1391 | 1393 | Note [Implicit parameters and ambiguity] |
-
diff --git a/compiler/typecheck/TcRnDriver.lhs b/compiler/typecheck/TcRnDriver.lhs
index 8a5aab5..97975de 100644
|
a
|
b
|
|
| 40 | 40 | import TcAnnotations |
| 41 | 41 | import TcBinds |
| 42 | 42 | import HeaderInfo ( mkPrelImports ) |
| 43 | | import TcType ( tidyTopType ) |
| | 43 | import TcType ( tidyTopType, tidyType ) |
| 44 | 44 | import TcDefaults |
| 45 | 45 | import TcEnv |
| 46 | 46 | import TcRules |
| … |
… |
|
| 100 | 100 | |
| 101 | 101 | import Control.Monad |
| 102 | 102 | |
| | 103 | import System.IO |
| | 104 | import TypeRep |
| | 105 | import qualified Data.Map as Map |
| | 106 | import TcType |
| | 107 | |
| 103 | 108 | #include "HsVersions.h" |
| 104 | 109 | \end{code} |
| 105 | 110 | |
| … |
… |
|
| 429 | 434 | simplifyTop lie ; |
| 430 | 435 | traceTc "Tc9" empty ; |
| 431 | 436 | |
| | 437 | traceRn (text "tcRnSrcDecls:" <+> (ppr lie)) ; |
| | 438 | |
| 432 | 439 | failIfErrsM ; -- Don't zonk if there have been errors |
| 433 | 440 | -- It's a waste of time; and we may get debug warnings |
| 434 | 441 | -- about strangely-typed TyCons! |
| … |
… |
|
| 461 | 468 | setGlobalTypeEnv tcg_env' final_type_env |
| 462 | 469 | } } |
| 463 | 470 | |
| | 471 | -- where |
| | 472 | |
| 464 | 473 | tc_rn_src_decls :: ModDetails |
| 465 | 474 | -> [LHsDecl RdrName] |
| 466 | 475 | -> TcM (TcGblEnv, TcLclEnv) |
| … |
… |
|
| 1423 | 1432 | -- it might have a rank-2 type (e.g. :t runST) |
| 1424 | 1433 | uniq <- newUnique ; |
| 1425 | 1434 | let { fresh_it = itName uniq (getLoc rdr_expr) } ; |
| 1426 | | ((_tc_expr, res_ty), lie) <- captureConstraints (tcInferRho rn_expr) ; |
| 1427 | | ((qtvs, dicts, _, _), lie_top) <- captureConstraints $ |
| | 1435 | ((_tc_expr, res_ty), lie) <- captureConstraints (tcInferRho rn_expr) ; |
| | 1436 | |
| | 1437 | |
| | 1438 | (g, l) <- getEnvs ; |
| | 1439 | holes <- readTcRef $ tcl_holes l ; |
| | 1440 | |
| | 1441 | ((qtvs, dicts, _, _), lie_top) <- captureConstraints $ |
| 1428 | 1442 | {-# SCC "simplifyInfer" #-} |
| 1429 | 1443 | simplifyInfer True {- Free vars are closed -} |
| 1430 | 1444 | False {- No MR for now -} |
| 1431 | | [(fresh_it, res_ty)] |
| | 1445 | ([(fresh_it, res_ty)]) -- ++ (map (\(nm,(ty,_)) -> (holeNameName nm, ty)) $ Map.toList holes)) |
| 1432 | 1446 | lie ; |
| | 1447 | let { (holes, dicts') = splitEvs dicts [] [] } ; |
| | 1448 | |
| | 1449 | traceRn (text "tcRnExpr1:" <+> (ppr holes <+> ppr dicts')) ; |
| | 1450 | |
| 1433 | 1451 | _ <- simplifyInteractive lie_top ; -- Ignore the dicionary bindings |
| | 1452 | |
| | 1453 | traceRn (text "tcRnExpr2:" <+> (ppr lie_top)) ; |
| | 1454 | |
| | 1455 | let { all_expr_ty = mkForAllTys qtvs (mkPiTypes dicts' res_ty) } ; |
| | 1456 | result <- zonkTcType all_expr_ty ; |
| | 1457 | |
| 1434 | 1458 | |
| 1435 | | let { all_expr_ty = mkForAllTys qtvs (mkPiTypes dicts res_ty) } ; |
| 1436 | | zonkTcType all_expr_ty |
| | 1459 | zonked_holes <- zonkHoles $ map (apsnd (mkForAllTys qtvs) . apsnd (mkPiTypes dicts') . unwrapHole . varType) $ holes ; |
| | 1460 | |
| | 1461 | let { (env, tidied_holes) = apsnd (map (apsnd split)) $ foldr tidy (emptyTidyEnv, []) zonked_holes } ; |
| | 1462 | |
| | 1463 | liftIO $ putStrLn $ showSDoc ((ptext $ sLit "Found the following holes: ") |
| | 1464 | $+$ (vcat $ map (\(nm, ty) -> text "_" <> ppr nm <+> colon <> colon <+> ppr ty) tidied_holes)); |
| | 1465 | |
| | 1466 | return $ snd $ tidyOpenType env result |
| 1437 | 1467 | } |
| | 1468 | where tidy (nm, ty) (env, tys) = let (env', ty') = tidyOpenType env ty |
| | 1469 | in (env', (nm, ty') : tys) |
| | 1470 | |
| | 1471 | split t = let (_, ctxt, ty') = tcSplitSigmaTy $ tidyTopType t |
| | 1472 | in mkPhiTy ctxt ty' |
| | 1473 | |
| | 1474 | splitEvs [] hls dcts = (hls, dcts) |
| | 1475 | splitEvs (evvar:xs) hls dcts = case classifyPredType $ varType evvar of |
| | 1476 | HolePred {} -> splitEvs xs (evvar:hls) dcts |
| | 1477 | _ -> splitEvs xs hls (evvar:dcts) |
| | 1478 | -- unwrap what was wrapped in mkHolePred |
| | 1479 | unwrapHole (TyConApp nm [ty]) = (nm, ty) |
| | 1480 | |
| | 1481 | -- zonk the holes, but keep the name |
| | 1482 | zonkHoles = mapM (\(nm, ty) -> liftM (\t -> (nm, t)) $ zonkTcType ty) |
| | 1483 | |
| | 1484 | apsnd f (a, b) = (a, f b) |
| | 1485 | |
| | 1486 | f (_, b) = let (Just (ATyCon tc)) = wiredInNameTyThing_maybe b |
| | 1487 | (Just (_, ty, _)) = trace ("unwrapNewTyCon_maybe" ++ (showSDoc $ ppr tc)) $ unwrapNewTyCon_maybe tc |
| | 1488 | in (b, ty) |
| 1438 | 1489 | |
| 1439 | 1490 | -------------------------- |
| 1440 | 1491 | tcRnImportDecls :: HscEnv |
-
diff --git a/compiler/typecheck/TcRnMonad.lhs b/compiler/typecheck/TcRnMonad.lhs
index 77a1230..37f1d5a 100644
|
a
|
b
|
|
| 53 | 53 | import Data.IORef |
| 54 | 54 | import qualified Data.Set as Set |
| 55 | 55 | import Control.Monad |
| | 56 | |
| | 57 | import qualified Data.Map as Map |
| 56 | 58 | \end{code} |
| 57 | 59 | |
| 58 | 60 | |
| … |
… |
|
| 86 | 88 | infer_var <- newIORef True ; |
| 87 | 89 | lie_var <- newIORef emptyWC ; |
| 88 | 90 | dfun_n_var <- newIORef emptyOccSet ; |
| | 91 | holes_var <- newIORef Map.empty ; |
| 89 | 92 | type_env_var <- case hsc_type_env_var hsc_env of { |
| 90 | 93 | Just (_mod, te_var) -> return te_var ; |
| 91 | 94 | Nothing -> newIORef emptyNameEnv } ; |
| … |
… |
|
| 151 | 154 | tcl_tyvars = tvs_var, |
| 152 | 155 | tcl_lie = lie_var, |
| 153 | 156 | tcl_meta = meta_var, |
| 154 | | tcl_untch = initTyVarUnique |
| | 157 | tcl_untch = initTyVarUnique, |
| | 158 | tcl_holes = holes_var |
| 155 | 159 | } ; |
| 156 | 160 | } ; |
| 157 | 161 | |
-
diff --git a/compiler/typecheck/TcRnTypes.lhs b/compiler/typecheck/TcRnTypes.lhs
index b353943..36c7ae0 100644
|
a
|
b
|
|
| 54 | 54 | Xi, Ct(..), Cts, emptyCts, andCts, andManyCts, |
| 55 | 55 | singleCt, extendCts, isEmptyCts, isCTyEqCan, |
| 56 | 56 | isCDictCan_Maybe, isCIPCan_Maybe, isCFunEqCan_Maybe, |
| | 57 | isCHoleCan_Maybe, isCHoleCan, |
| 57 | 58 | isCIrredEvCan, isCNonCanonical, isWantedCt, isDerivedCt, |
| 58 | 59 | isGivenCt_maybe, isGivenOrSolvedCt, |
| 59 | 60 | ctWantedLoc, |
| 60 | 61 | SubGoalDepth, mkNonCanonical, ctPred, |
| 61 | 62 | |
| 62 | 63 | WantedConstraints(..), insolubleWC, emptyWC, isEmptyWC, |
| 63 | | andWC, addFlats, addImplics, mkFlatWC, |
| | 64 | andWC, unionsWC, addFlats, addImplics, mkFlatWC, |
| 64 | 65 | |
| 65 | 66 | Implication(..), |
| 66 | 67 | CtLoc(..), ctLocSpan, ctLocOrigin, setCtLocOrigin, |
| … |
… |
|
| 123 | 124 | |
| 124 | 125 | import Data.Set (Set) |
| 125 | 126 | |
| | 127 | import UniqSet |
| | 128 | import qualified Data.Map as Map |
| 126 | 129 | \end{code} |
| 127 | 130 | |
| 128 | 131 | |
| … |
… |
|
| 444 | 447 | -- TcMetaTyVars have |
| 445 | 448 | tcl_meta :: TcRef Unique, -- The next free unique for TcMetaTyVars |
| 446 | 449 | -- Guaranteed to be allocated linearly |
| 447 | | tcl_untch :: Unique -- Any TcMetaTyVar with |
| | 450 | tcl_untch :: Unique, -- Any TcMetaTyVar with |
| 448 | 451 | -- unique >= tcl_untch is touchable |
| 449 | 452 | -- unique < tcl_untch is untouchable |
| | 453 | tcl_holes :: TcRef (Map.Map (HoleName Name) (Type, TcRef WantedConstraints)) |
| 450 | 454 | } |
| 451 | 455 | |
| 452 | 456 | type TcTypeEnv = NameEnv TcTyThing |
| … |
… |
|
| 908 | 912 | cc_depth :: SubGoalDepth |
| 909 | 913 | } |
| 910 | 914 | |
| | 915 | | CHoleCan { |
| | 916 | cc_id :: EvVar, |
| | 917 | cc_flavor :: CtFlavor, |
| | 918 | cc_hole_nm :: HoleName Name, |
| | 919 | cc_hole_ty :: TcTauType, -- Not a Xi! See same not as above |
| | 920 | cc_depth :: SubGoalDepth -- See Note [WorkList] |
| | 921 | } |
| | 922 | |
| 911 | 923 | \end{code} |
| 912 | 924 | |
| 913 | 925 | \begin{code} |
| … |
… |
|
| 925 | 937 | ctPred (CIPCan { cc_ip_nm = nm, cc_ip_ty = xi }) |
| 926 | 938 | = mkIPPred nm xi |
| 927 | 939 | ctPred (CIrredEvCan { cc_ty = xi }) = xi |
| | 940 | ctPred (CHoleCan { cc_hole_nm = nm, cc_hole_ty = xi}) |
| | 941 | = mkHolePred nm xi |
| 928 | 942 | \end{code} |
| 929 | 943 | |
| 930 | 944 | |
| … |
… |
|
| 977 | 991 | isCNonCanonical :: Ct -> Bool |
| 978 | 992 | isCNonCanonical (CNonCanonical {}) = True |
| 979 | 993 | isCNonCanonical _ = False |
| | 994 | |
| | 995 | isCHoleCan :: Ct -> Bool |
| | 996 | isCHoleCan (CHoleCan {}) = True |
| | 997 | isCHoleCan _ = False |
| | 998 | |
| | 999 | isCHoleCan_Maybe :: Ct -> Maybe (HoleName Name) |
| | 1000 | isCHoleCan_Maybe (CHoleCan { cc_hole_nm = nm }) = Just nm |
| | 1001 | isCHoleCan_Maybe _ = Nothing |
| 980 | 1002 | \end{code} |
| 981 | 1003 | |
| 982 | 1004 | \begin{code} |
| … |
… |
|
| 992 | 1014 | CDictCan {} -> "CDictCan" |
| 993 | 1015 | CIPCan {} -> "CIPCan" |
| 994 | 1016 | CIrredEvCan {} -> "CIrredEvCan" |
| | 1017 | CHoleCan {} -> "CHoleCan" |
| 995 | 1018 | \end{code} |
| 996 | 1019 | |
| 997 | 1020 | \begin{code} |
| … |
… |
|
| 1058 | 1081 | , wc_impl = i1 `unionBags` i2 |
| 1059 | 1082 | , wc_insol = n1 `unionBags` n2 } |
| 1060 | 1083 | |
| | 1084 | unionsWC :: [WantedConstraints] -> WantedConstraints |
| | 1085 | unionsWC = foldr andWC emptyWC |
| | 1086 | |
| 1061 | 1087 | addFlats :: WantedConstraints -> Bag Ct -> WantedConstraints |
| 1062 | 1088 | addFlats wc cts |
| 1063 | 1089 | = wc { wc_flat = wc_flat wc `unionBags` cts } |
-
diff --git a/compiler/typecheck/TcSMonad.lhs b/compiler/typecheck/TcSMonad.lhs
index 77c81e7..5d2fa67 100644
|
a
|
b
|
|
| 329 | 329 | , cts_wanted :: UniqFM Cts } |
| 330 | 330 | -- Invariant: all Wanted |
| 331 | 331 | |
| | 332 | instance Outputable (CCanMap a) where |
| | 333 | ppr (CCanMap given derived wanted) = ptext (sLit "CCanMap") <+> (ppr given) <+> (ppr derived) <+> (ppr wanted) |
| | 334 | |
| 332 | 335 | cCanMapToBag :: CCanMap a -> Cts |
| 333 | 336 | cCanMapToBag cmap = foldUFM unionBags rest_wder (cts_given cmap) |
| 334 | 337 | where rest_wder = foldUFM unionBags rest_der (cts_wanted cmap) |
| … |
… |
|
| 415 | 418 | |
| 416 | 419 | , inert_irreds :: Cts -- Irreducible predicates |
| 417 | 420 | , inert_frozen :: Cts -- All non-canonicals are kept here (as frozen errors) |
| | 421 | , inert_holes :: CCanMap (HoleName Name) |
| 418 | 422 | } |
| 419 | 423 | |
| 420 | 424 | |
| … |
… |
|
| 453 | 457 | , vcat (map ppr (Bag.bagToList $ cCanMapToBag (inert_dicts is))) |
| 454 | 458 | , vcat (map ppr (Bag.bagToList $ cCanMapToBag (inert_ips is))) |
| 455 | 459 | , vcat (map ppr (Bag.bagToList $ ctTypeMapCts (inert_funeqs is))) |
| | 460 | , vcat (map ppr (Bag.bagToList $ cCanMapToBag (inert_holes is))) |
| 456 | 461 | , text "Frozen errors =" <+> -- Clearly print frozen errors |
| 457 | 462 | braces (vcat (map ppr (Bag.bagToList $ inert_frozen is))) |
| 458 | 463 | , text "Warning: Not displaying cached (solved) constraints" |
| … |
… |
|
| 466 | 471 | , inert_dicts = emptyCCanMap |
| 467 | 472 | , inert_ips = emptyCCanMap |
| 468 | 473 | , inert_funeqs = emptyTM |
| | 474 | , inert_holes = emptyCCanMap |
| 469 | 475 | } |
| 470 | 476 | |
| 471 | 477 | |
| … |
… |
|
| 504 | 510 | upd_funeqs Nothing = Just item |
| 505 | 511 | upd_funeqs (Just _alredy_there) = panic "updInertSet: item already there!" |
| 506 | 512 | in is { inert_funeqs = alterTM pty upd_funeqs (inert_funeqs is) } |
| 507 | | |
| | 513 | |
| | 514 | | Just x <- isCHoleCan_Maybe item |
| | 515 | = is { inert_holes = updCCanMap (x,item) (inert_holes is) } |
| 508 | 516 | | otherwise |
| 509 | | = is { inert_frozen = inert_frozen is `Bag.snocBag` item } |
| | 517 | = trace "updInertSet" $ is { inert_frozen = inert_frozen is `Bag.snocBag` item } |
| 510 | 518 | |
| 511 | 519 | updInertSetTcS :: AtomicInert -> TcS () |
| 512 | 520 | -- Add a new item in the inerts of the monad |
| … |
… |
|
| 557 | 565 | , inert_irreds = solved_irreds |
| 558 | 566 | , inert_frozen = emptyCts |
| 559 | 567 | , inert_funeqs = solved_funeqs |
| | 568 | , inert_holes = solved_holes |
| 560 | 569 | } |
| 561 | 570 | in ((inert_frozen is, unsolved), is_solved) |
| 562 | 571 | |
| … |
… |
|
| 570 | 579 | |
| 571 | 580 | (unsolved_funeqs, solved_funeqs) = extractUnsolvedCtTypeMap (inert_funeqs is) |
| 572 | 581 | |
| | 582 | (unsolved_holes, solved_holes) = extractUnsolvedCMap (inert_holes is) |
| | 583 | |
| 573 | 584 | unsolved = unsolved_eqs `unionBags` unsolved_irreds `unionBags` |
| 574 | 585 | unsolved_ips `unionBags` unsolved_dicts `unionBags` unsolved_funeqs |
| | 586 | `unionBags` unsolved_holes |
| 575 | 587 | |
| 576 | 588 | extractUnsolvedCtTypeMap :: TypeMap Ct -> (Cts,TypeMap Ct) |
| 577 | 589 | extractUnsolvedCtTypeMap |
| … |
… |
|
| 596 | 608 | extract_inert_relevants (CIrredEvCan { }) is = |
| 597 | 609 | let cts = inert_irreds is |
| 598 | 610 | in (cts, is { inert_irreds = emptyCts }) |
| | 611 | extract_inert_relevants (CHoleCan { cc_hole_nm = nm }) is = |
| | 612 | let (cts, holes_map) = getRelevantCts nm (inert_holes is) |
| | 613 | in (cts, is { inert_holes = holes_map }) |
| 599 | 614 | extract_inert_relevants _ is = (emptyCts,is) |
| 600 | 615 | \end{code} |
| 601 | 616 | |
-
diff --git a/compiler/typecheck/TcSimplify.lhs b/compiler/typecheck/TcSimplify.lhs
index ae948b5..35da625 100644
|
a
|
b
|
|
| 472 | 472 | -> Bool -- True <=> quantify over this wanted |
| 473 | 473 | quantifyMe qtvs ct |
| 474 | 474 | | isIPPred pred = True -- Note [Inheriting implicit parameters] |
| | 475 | | isHolePred pred = True |
| 475 | 476 | | otherwise = tyVarsOfType pred `intersectsVarSet` qtvs |
| 476 | 477 | where |
| 477 | 478 | pred = ctPred ct |
-
diff --git a/compiler/typecheck/TcType.lhs b/compiler/typecheck/TcType.lhs
index c947521..1a04aa1 100644
|
a
|
b
|
|
| 131 | 131 | mkTyVarTy, mkTyVarTys, mkTyConTy, |
| 132 | 132 | |
| 133 | 133 | isClassPred, isEqPred, isIPPred, |
| 134 | | mkClassPred, mkIPPred, |
| | 134 | mkClassPred, mkIPPred, isHolePred, |
| 135 | 135 | isDictLikeTy, |
| 136 | 136 | tcSplitDFunTy, tcSplitDFunHead, |
| 137 | 137 | mkEqPred, |
| … |
… |
|
| 306 | 306 | |
| 307 | 307 | | MetaTv MetaInfo (IORef MetaDetails) |
| 308 | 308 | |
| | 309 | instance Outputable TcTyVarDetails where |
| | 310 | ppr (SkolemTv b) = ptext (sLit "SkolemTv") <+> ppr b |
| | 311 | ppr RuntimeUnk = ptext (sLit "RuntimeUnk") |
| | 312 | ppr (FlatSkol ty) = ptext (sLit "FlatSkol") <+> ppr ty |
| | 313 | ppr (MetaTv info _) = ptext (sLit "MetaTv") <+> ppr info |
| | 314 | |
| 309 | 315 | vanillaSkolemTv, superSkolemTv :: TcTyVarDetails |
| 310 | 316 | -- See Note [Binding when looking up instances] in InstEnv |
| 311 | 317 | vanillaSkolemTv = SkolemTv False -- Might be instantiated |
| … |
… |
|
| 340 | 346 | -- UserTypeCtxt describes the origin of the polymorphic type |
| 341 | 347 | -- in the places where we need to an expression has that type |
| 342 | 348 | |
| | 349 | instance Outputable MetaInfo where |
| | 350 | ppr TauTv = ptext (sLit "TauTv") |
| | 351 | ppr SigTv = ptext (sLit "SigTv") |
| | 352 | ppr TcsTv = ptext (sLit "TcsTv") |
| | 353 | |
| 343 | 354 | data UserTypeCtxt |
| 344 | 355 | = FunSigCtxt Name -- Function type signature |
| 345 | 356 | -- Also used for types in SPECIALISE pragmas |
-
diff --git a/compiler/types/TyCon.lhs b/compiler/types/TyCon.lhs
index 0543092..8d46adb 100644
|
a
|
b
|
|
| 65 | 65 | tyConStupidTheta, |
| 66 | 66 | tyConArity, |
| 67 | 67 | tyConParent, |
| 68 | | tyConTuple_maybe, tyConClass_maybe, tyConIP_maybe, |
| | 68 | tyConTuple_maybe, tyConClass_maybe, tyConIP_maybe, tyConHole_maybe, |
| 69 | 69 | tyConFamInst_maybe, tyConFamInstSig_maybe, tyConFamilyCoercion_maybe, |
| 70 | 70 | synTyConDefn, synTyConRhs, synTyConType, |
| 71 | 71 | tyConExtName, -- External name for foreign types |
| … |
… |
|
| 551 | 551 | -- data R:TList a = ... |
| 552 | 552 | -- axiom co a :: T [a] ~ R:TList a |
| 553 | 553 | -- with R:TList's algTcParent = FamInstTyCon T [a] co |
| | 554 | | HoleTyCon (HoleName Name) |
| 554 | 555 | |
| 555 | 556 | instance Outputable TyConParent where |
| 556 | 557 | ppr NoParentTyCon = text "No parent" |
| … |
… |
|
| 566 | 567 | okParent tc_name (ClassTyCon cls) = tc_name == tyConName (classTyCon cls) |
| 567 | 568 | okParent tc_name (IPTyCon ip) = tc_name == ipTyConName ip |
| 568 | 569 | okParent _ (FamInstTyCon _ fam_tc tys) = tyConArity fam_tc == length tys |
| | 570 | okParent tc_name (HoleTyCon hole) = tc_name == holeNameName hole |
| 569 | 571 | |
| 570 | 572 | isNoParent :: TyConParent -> Bool |
| 571 | 573 | isNoParent NoParentTyCon = True |
| … |
… |
|
| 1409 | 1411 | tyConIP_maybe (AlgTyCon {algTcParent = IPTyCon ip}) = Just ip |
| 1410 | 1412 | tyConIP_maybe _ = Nothing |
| 1411 | 1413 | |
| | 1414 | tyConHole_maybe :: TyCon -> Maybe (HoleName Name) |
| | 1415 | tyConHole_maybe (AlgTyCon {algTcParent = HoleTyCon name}) = Just name |
| | 1416 | tyConHole_maybe _ = Nothing |
| | 1417 | |
| 1412 | 1418 | ---------------------------------------------------------------------------- |
| 1413 | 1419 | tyConParent :: TyCon -> TyConParent |
| 1414 | 1420 | tyConParent (AlgTyCon {algTcParent = parent}) = parent |
-
diff --git a/compiler/types/Type.lhs b/compiler/types/Type.lhs
index 114e3e9..0547274 100644
|
a
|
b
|
|
| 49 | 49 | mkFamilyTyConApp, |
| 50 | 50 | isDictLikeTy, |
| 51 | 51 | mkEqPred, mkClassPred, |
| 52 | | mkIPPred, |
| 53 | | noParenPred, isClassPred, isEqPred, isIPPred, |
| | 52 | mkIPPred, mkHolePred, |
| | 53 | noParenPred, isClassPred, isEqPred, isIPPred, isHolePred, |
| 54 | 54 | mkPrimEqType, |
| 55 | 55 | |
| 56 | 56 | -- Deconstructing predicate types |
| … |
… |
|
| 60 | 60 | getIPPredTy_maybe, |
| 61 | 61 | |
| 62 | 62 | -- ** Common type constructors |
| 63 | | funTyCon, |
| | 63 | funTyCon, holeTyCon, |
| 64 | 64 | |
| 65 | 65 | -- ** Predicates on types |
| 66 | 66 | isTypeVar, isKindVar, |
| … |
… |
|
| 154 | 154 | import TysPrim |
| 155 | 155 | import {-# SOURCE #-} TysWiredIn ( eqTyCon, mkBoxedTupleTy ) |
| 156 | 156 | import PrelNames ( eqTyConKey ) |
| | 157 | import Name |
| 157 | 158 | |
| 158 | 159 | -- others |
| 159 | 160 | import {-# SOURCE #-} IParam ( ipTyCon ) |
| 160 | 161 | import Unique ( Unique, hasKey ) |
| 161 | | import BasicTypes ( IPName(..) ) |
| | 162 | import BasicTypes ( IPName(..), HoleName(..), holeNameName ) |
| 162 | 163 | import Name ( Name ) |
| 163 | 164 | import NameSet |
| 164 | 165 | import StaticFlags |
| … |
… |
|
| 815 | 816 | isKindTy :: Type -> Bool |
| 816 | 817 | isKindTy = isSuperKind . typeKind |
| 817 | 818 | |
| 818 | | isClassPred, isEqPred, isIPPred :: PredType -> Bool |
| | 819 | isClassPred, isEqPred, isIPPred, isHolePred :: PredType -> Bool |
| 819 | 820 | isClassPred ty = case tyConAppTyCon_maybe ty of |
| 820 | 821 | Just tyCon | isClassTyCon tyCon -> True |
| 821 | 822 | _ -> False |
| … |
… |
|
| 825 | 826 | isIPPred ty = case tyConAppTyCon_maybe ty of |
| 826 | 827 | Just tyCon | Just _ <- tyConIP_maybe tyCon -> True |
| 827 | 828 | _ -> False |
| | 829 | isHolePred ty = case tyConAppTyCon_maybe ty of |
| | 830 | Just tycon | Just _ <- tyConHole_maybe tycon -> True |
| | 831 | _ -> False |
| 828 | 832 | \end{code} |
| 829 | 833 | |
| 830 | 834 | Make PredTypes |
| … |
… |
|
| 856 | 860 | mkIPPred ip ty = TyConApp (ipTyCon ip) [ty] |
| 857 | 861 | \end{code} |
| 858 | 862 | |
| | 863 | \begin{code} |
| | 864 | mkHolePred :: HoleName Name -> Type -> PredType |
| | 865 | mkHolePred name ty = TyConApp (holeTyCon name) [ty] |
| | 866 | |
| | 867 | holeTyCon :: HoleName Name -> TyCon |
| | 868 | holeTyCon name = case wiredInNameTyThing_maybe $ holeNameName name of |
| | 869 | Just (ATyCon tc) -> tc |
| | 870 | _ -> pprPanic "holeTyCon" (ppr name) |
| | 871 | \end{code} |
| | 872 | |
| 859 | 873 | --------------------- Dictionary types --------------------------------- |
| 860 | 874 | \begin{code} |
| 861 | 875 | mkClassPred :: Class -> [Type] -> PredType |
| … |
… |
|
| 911 | 925 | | IPPred (IPName Name) Type |
| 912 | 926 | | TuplePred [PredType] |
| 913 | 927 | | IrredPred PredType |
| | 928 | | HolePred (HoleName Name) Type |
| 914 | 929 | |
| 915 | 930 | predTreePredType :: PredTree -> PredType |
| 916 | 931 | predTreePredType (ClassPred clas tys) = mkClassPred clas tys |
| … |
… |
|
| 931 | 946 | -> IPPred ip ty |
| 932 | 947 | Just (tc, tys) | isTupleTyCon tc |
| 933 | 948 | -> TuplePred tys |
| | 949 | Just (tc, tys) | Just name <- tyConHole_maybe tc |
| | 950 | , let [ty] = tys |
| | 951 | -> HolePred name ty |
| 934 | 952 | _ -> IrredPred ev_ty |
| 935 | 953 | \end{code} |
| 936 | 954 | |