You can do it:
(defun pretty-lambdas-haskell () (font-lock-add-keywords nil `((,(concat "\\(" (regexp-quote "\\") "\\)") (0 (progn (compose-region (match-beginning 1) (match-end 1) ,(make-char 'greek-iso8859-7 107)) nil)))))) (add-hook 'haskell-mode-hook 'pretty-lambdas-haskell)
This adds a lambda as a keyword, which means that it will not appear in escape sequences in strings, for example (TODO: this is not the case after changing things). ,(make-char 'greek-iso8859-7 107) , of course, is equivalent to ?λ , but you must make sure that your Emacs init file is encoded as unicode in this case.
You can also enable full blocking of character fonts and use the font better (read: with wider arrows) like Pragmata Pro , Inconsolata or Ubuntu Monospace . I use the following code to select a good font:
(defun font-existsp (font) "Check to see if the named FONT is available." (if (null (x-list-fonts font)) nil t)) (require 'cl) (defun font-avail (fonts) "Finds the available fonts." (remove-if-not 'font-existsp fonts)) (defvar font-preferences '("PragmataPro" "Inconsolata" "DejaVu Sans Mono" "Bitstream Vera Sans Mono" "Anonymous Pro" "Menlo" "Consolas")) (unless (eq window-system nil) (let ((fonts (font-avail font-preferences))) (unless (null fonts) (set-face-attribute 'default nil :font (car fonts)))))
dflemstr
source share