+\begin{code}
+showForErr :: Outputable a => a -> String -- Boring but useful
+showForErr thing = ppShow 80 (ppr PprForUser thing)
+
+mkErrorAppDs :: Id -- The error function
+ -> Type -- Type to which it should be applied
+ -> String -- The error message string to pass
+ -> DsM CoreExpr
+
+mkErrorAppDs err_id ty msg
+ = getSrcLocDs `thenDs` \ (file, line) ->
+ let
+ full_msg = file ++ "|" ++ line ++ "|" ++msg
+ msg_lit = NoRepStr (_PK_ full_msg)
+ in
+ returnDs (mkApp (Var err_id) [] [ty] [LitArg msg_lit])
+\end{code}
+