Note [Using typesAreApart when calling mightMentionIP]
We call 'mightMentionIP' in two situations:
(1) to check that a predicate does not contain any implicit parameters
IP str ty, for a fixed literal str and any type ty,
(2) to check that a predicate does not contain any HasCallStack or
HasExceptionContext constraints.
In both of these cases, we want to be sure, so we should be conservative:
For (1), the predicate might contain an implicit parameter IP Str a, where
Str is a type family such as:
type family MyStr where MyStr = "abc"
To safeguard against this (niche) situation, instead of doing a simple
type equality check, we use 'typesAreApart'. This allows us to recognise
that 'IP MyStr a' contains an implicit parameter of the form 'IP "abc" ty'.
For (2), we similarly might have
type family MyCallStack where MyCallStack = CallStack
Again, here we use 'typesAreApart'. This allows us to see that
(?foo :: MyCallStack)
is indeed a CallStack constraint, hidden under a type family. References 0
This Note does not link to any other.
Referenced by 3
- GHC.Tc.Solver.Monad call site ×2
- Using isCallStackTy in mightMentionIP GHC.Tc.Solver.Monad