- | UnknownOrigin -- Help! I give up...
-\end{code}
-
-\begin{code}
--- During deriving and instance specialisation operations
--- we can't get the instances of the class from inside the
--- class, because the latter ain't ready yet. Instead we
--- find a mapping from classes to envts inside the dict origin.
-
-get_inst_env :: Class -> InstOrigin s -> ClassInstEnv
--- get_inst_env clas (DerivingOrigin inst_mapper _ _)
--- = fst (inst_mapper clas)
-get_inst_env clas (InstanceSpecOrigin inst_mapper _ _)
- = fst (inst_mapper clas)
-get_inst_env clas other_orig = classInstEnv clas
-
-
-pprOrigin :: String -> InstOrigin s -> SrcLoc -> Error
-
-pprOrigin hdr orig locn
- = addErrLoc locn hdr $ \ sty ->
- case orig of
- OccurrenceOf id ->
- ppBesides [ppPStr SLIT("at a use of an overloaded identifier: `"),
- ppr sty id, ppChar '\'']
- OccurrenceOfCon id ->
- ppBesides [ppPStr SLIT("at a use of an overloaded constructor: `"),
- ppr sty id, ppChar '\'']
- InstanceDeclOrigin ->
- ppStr "in an instance declaration"
- LiteralOrigin lit ->
- ppCat [ppStr "at an overloaded literal:", ppr sty lit]
- ArithSeqOrigin seq ->
- ppCat [ppStr "at an arithmetic sequence:", ppr sty seq]
- SignatureOrigin ->
- ppStr "in a type signature"
- DoOrigin ->
- ppStr "in a do statement"
- ClassDeclOrigin ->
- ppStr "in a class declaration"
- InstanceSpecOrigin _ clas ty ->
- ppBesides [ppStr "in a SPECIALIZE instance pragma; class \"",
- ppr sty clas, ppStr "\" type: ", ppr sty ty]
- ValSpecOrigin name ->
- ppBesides [ppStr "in a SPECIALIZE user-pragma for `",
- ppr sty name, ppStr "'"]
- CCallOrigin clabel Nothing{-ccall result-} ->
- ppBesides [ppStr "in the result of the _ccall_ to `",
- ppStr clabel, ppStr "'"]
- CCallOrigin clabel (Just arg_expr) ->
- ppBesides [ppStr "in an argument in the _ccall_ to `",
- ppStr clabel, ppStr "', namely: ", ppr sty arg_expr]
- LitLitOrigin s ->
- ppBesides [ppStr "in this ``literal-literal'': ", ppStr s]
- UnknownOrigin ->
- ppStr "in... oops -- I don't know where the overloading came from!"
+syntaxNameCtxt name orig ty tidy_env
+ = getInstLoc orig `thenM` \ inst_loc ->
+ let
+ msg = vcat [ptext SLIT("When checking that") <+> quotes (ppr name) <+>
+ ptext SLIT("(needed by a syntactic construct)"),
+ nest 2 (ptext SLIT("has the required type:") <+> ppr (tidyType tidy_env ty)),
+ nest 2 (pprInstLoc inst_loc)]
+ in
+ returnM (tidy_env, msg)