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:

    literate={use of}{use of}6
<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

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).

  • 1
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.