diff options
author | sheaf <sam.derbyshire@gmail.com> | 2021-10-15 23:09:39 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-10-17 14:06:46 -0400 |
commit | 81740ce83976e9d6b68594f8a4b489452cca56e5 (patch) | |
tree | 7b41d1529975c2f78eaced81e26e4722d34c212f /compiler/GHC/Tc/Solver/Interact.hs | |
parent | 65bf3992aebb3c08f0c4e13a3fb89dd5620015a9 (diff) | |
download | haskell-81740ce83976e9d6b68594f8a4b489452cca56e5.tar.gz |
Introduce Concrete# for representation polymorphism checks
PHASE 1: we never rewrite Concrete# evidence.
This patch migrates all the representation polymorphism checks to
the typechecker, using a new constraint form
Concrete# :: forall k. k -> TupleRep '[]
Whenever a type `ty` must be representation-polymorphic
(e.g. it is the type of an argument to a function), we emit a new
`Concrete# ty` Wanted constraint. If this constraint goes
unsolved, we report a representation-polymorphism error to the user.
The 'FRROrigin' datatype keeps track of the context of the
representation-polymorphism check, for more informative error messages.
This paves the way for further improvements, such as
allowing type families in RuntimeReps and improving the soundness
of typed Template Haskell. This is left as future work (PHASE 2).
fixes #17907 #20277 #20330 #20423 #20426
updates haddock submodule
-------------------------
Metric Decrease:
T5642
-------------------------
Diffstat (limited to 'compiler/GHC/Tc/Solver/Interact.hs')
-rw-r--r-- | compiler/GHC/Tc/Solver/Interact.hs | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/compiler/GHC/Tc/Solver/Interact.hs b/compiler/GHC/Tc/Solver/Interact.hs index e583861196..ff3b3e7fcd 100644 --- a/compiler/GHC/Tc/Solver/Interact.hs +++ b/compiler/GHC/Tc/Solver/Interact.hs @@ -1,5 +1,4 @@ - {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -431,9 +430,10 @@ interactWithInertsStage wi = do { inerts <- getTcSInerts ; let ics = inert_cans inerts ; case wi of - CEqCan {} -> interactEq ics wi - CIrredCan {} -> interactIrred ics wi - CDictCan {} -> interactDict ics wi + CEqCan {} -> interactEq ics wi + CIrredCan {} -> interactIrred ics wi + CDictCan {} -> interactDict ics wi + CSpecialCan {} -> continueWith wi -- cannot have Special Givens, so nothing to interact with _ -> pprPanic "interactWithInerts" (ppr wi) } -- CNonCanonical have been canonicalised @@ -1905,13 +1905,23 @@ topReactionsStage :: WorkItem -> TcS (StopOrContinue Ct) topReactionsStage work_item = do { traceTcS "doTopReact" (ppr work_item) ; case work_item of - CDictCan {} -> do { inerts <- getTcSInerts - ; doTopReactDict inerts work_item } - CEqCan {} -> doTopReactEq work_item - CIrredCan {} -> doTopReactOther work_item - _ -> -- Any other work item does not react with any top-level equations - continueWith work_item } + CDictCan {} -> + do { inerts <- getTcSInerts + ; doTopReactDict inerts work_item } + + CEqCan {} -> + doTopReactEq work_item + + CSpecialCan {} -> + -- No top-level interactions for special constraints. + continueWith work_item + + CIrredCan {} -> + doTopReactOther work_item + + -- Any other work item does not react with any top-level equations + _ -> continueWith work_item } -------------------- doTopReactOther :: Ct -> TcS (StopOrContinue Ct) @@ -1939,6 +1949,12 @@ doTopReactOther work_item loc = ctEvLoc ev pred = ctEvPred ev +{-******************************************************************** +* * + Top-level reaction for equality constraints (CEqCan) +* * +********************************************************************-} + doTopReactEqPred :: Ct -> EqRel -> TcType -> TcType -> TcS (StopOrContinue Ct) doTopReactEqPred work_item eq_rel t1 t2 -- See Note [Looking up primitive equalities in quantified constraints] |