Another question on Emacs 24.1 and Haskell. I’ve noticed that it does indenting for me and it does very basic highlighting for me (types are in green, for example). But out-of-box Emacs 24.1 doesn’t highlight commonly used functions like foldr, map, etc. Is there an ability for Emacs and haskell-mode to highlight commonly used functions?
Another question on Emacs 24.1 and Haskell. I’ve noticed that it does indenting for
Share
Fundamentally, standard library functions are just that–functions. In fact, depending on your imports, any of them could be user-supplied rather than from the standard prelude! This actually happens often–for example, if you want to use
Control.Categoryyou usually hideidand replace it with a polymorphic version.So in short, there is no real reason to highlight standard functions. So I really doubt this functionality is present in the standard Haskell mode.
That said, this is Emacs. You can easily add anything you want. If you have a list of all the function names you want to highlight, it should not be difficult to add that to the Haskell mode.
You can add your new functions to the haskell-mode highlighting with code something like this in your
.emacsfile:The weird looking string is an Emacs-style regular expression.
\<and\>are like\band\(,\|and\)are for alternation inside a group. Since there are no regex literals, every\has to be escaped inside the string. The regex would be more readable as\<\(map\|foldr\|foldl\)\>. You can easily add other function names by adding new cases to the expression.The
(:foreground "#3366FF")just sets the color of the text to a rather fetching shade of blue.