# Avoid highlighting keywords following certain words in listings

instance and of are keywords in Haskell. But they also appear in error messages like No instance for... arising from the use of.... I'd like to tell listings that instance after No shouldn't be considered a keyword (while not removing highlighting entirely). Is it possible?

Based on Forbidding keywords in listings, I hoped

literate={use of}{use of}6


would do the trick, but it doesn't (weirdly, giving 11 as the length for No instance produces "Improper alphabetic constant" and "Missing number, treated as zero").

Example document:

\documentclass[12pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1,T2A]{fontenc}
\usepackage{color}
\usepackage{listings}
\lstset{
basicstyle=\ttfamily\footnotesize,
keywordstyle=\color{blue},
literate={use of}{use of}6
}
\begin{document}
\begin{lstlisting}
<interactive>:11:1: error:
No instance for (Num Bool) arising from a use of '+'
In the expression: True + False
In an equation for 'it': it = True + False
\end{lstlisting}
\end{document}


The desired result is that Num, Bool, True and False are still highlighted, but instance and of shouldn't be (preferably without changing contents of lstlisting environment).

• Always add a complete example. That makes it much easier to test and analyze a problem. – Ulrike Fischer Feb 17 '18 at 9:56
• I don't know for sure and since you don't show complete code can't really tell, but perhaps you have to group the 11 to {11}. – Skillmon Feb 17 '18 at 10:08
• @UlrikeFischer Sorry again, fixed. – Alexey Romanov Feb 17 '18 at 10:21
• @CarLaTeX This is an answer to the "weirdly..." side note, but not to the question itself. – Alexey Romanov Mar 7 '18 at 18:15
• Sorry, I think it was. – CarLaTeX Mar 7 '18 at 18:48