Note [Call-stack tracing of pattern synonyms]
Consider f :: HasCallStack => blah pattern Annotated :: HasCallStack => (CallStack, a) -> a pattern Annotated x <- (f -> x) When we pattern-match against `Annotated` we will call `f`, and must pass a call-stack. We may want `Annotated` itself to propagate the call stack, so we give it a HasCallStack constraint too. But then we expect to see `Annotated` in the call stack. This is achieve easily, but a bit trickily. When we instantiate Annotated's "required" constraints, in tcPatSynPat, give them a CtOrigin of (OccurrenceOf "Annotated"). That way the special magic in GHC.Tc.Solver.Dict.canDictCt which deals with CallStack constraints will kick in: that logic only fires on constraints whose Origin is (OccurrenceOf f). See also Note [Overview of implicit CallStacks] in GHC.Tc.Types.Evidence and Note [Solving CallStack constraints] in GHC.Tc.Solver.Dict
References 2
- Solving CallStack constraints GHC.Tc.Solver.Dict
- Overview of implicit CallStacks GHC.Tc.Types.Evidence
Referenced by 1
- GHC.Tc.Gen.Pat call site