haskell-mode supports syntax highlighting via Emacs’ Font
Lock minor mode which should be enabled by default in current
Emacsen. See (emacs)Font Lock, for more information on how to
Syntax highlighting facilities parse strings and string escape sequences and are able to highlight unrecognized constructs.
Haskell Mode shows keywords, identifiers, operators, constructors and types in different colors.
There is also support to use mode-specific syntax highlighing for quasiquotes.
At this point quasi quotes for HTML, XML, shell scripts, Hamlet
templates and SQL are supported out of the box. Customize
haskell-font-lock-quasi-quote-modes to make sure your quoters are
The following customization variables are responsible for faces applied:
haskell-keyword-face: for keywords
haskell-type-face: for type names and type class names
haskell-constructor-face: for constructors
haskell-definition-face: function and operator name at the definition place
haskell-pragma-face: GHC pragmas
haskell-literate-comment-face: literate comments
haskell-quasi-quote-face: quasi quotes unless using mode specific highlighting
haskell-c2hs-hook-pair-face: c2hs hooks
haskell-c2hs-hook-name-face: c2hs hook names
All the above are available for customization.
GHC quasi quote syntax is ambiguous with list comprehension therefore syntax highlighting might get confused with situations like these:
result = [html| html <- htmlList] result = [html| <html><body>...</body></html> |]
Please use spaces around a list comprehension variable to make this unambiguous. Any of the following will work:
result = [ html| html <- htmlList] result = [html | html <- htmlList]
GHC’s ambiguity is an accident of the past but it is unlikely to be fixed due to backward compatibility baggage.